Search Results

Search found 6745 results on 270 pages for 'objective c'.

Page 21/270 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Using iterateFunc to call objective c method

    - by Matt Welch
    Using spacemanager, I need to perform an action on select bodies after each step, so I figured that defining my own C function for iterateFunc would be the way to go. Everything works great, except I'm not sure how to then call an obj c method in the same class. In other words, an obj c class contains both the c function replacing iterateFunc, and the method that needs to be called. I don't see how to tell the c function what 'self' is, such that I can call the method. As far as i can tell, there's no way to pass in any extra info to the new iterateFunc. Any ideas, or a better way to go about things?

    Read the article

  • Objective-C: Loop through NSDictionary to create seperate NSArray's

    - by Nic Hubbard
    I have a large NSDictionary structure that I need to loop through and create seperate NSArray's. Here is the structure: ( { id = { text = ""; }; sub = { text = " , "; }; text = ""; "thumb_url" = { text = ""; }; title = { text = "2010-2011"; }; type = { text = "title"; }; }, { id = { text = "76773"; }; sub = { text = "December 13, 2010"; }; text = ""; "thumb_url" = { text = "http://www.puc.edu/__data/assets/image/0004/76774/varieties/thumb.jpg"; }; title = { text = "College Days - Fall 2010"; }; type = { text = "gallery"; }; }, { id = { text = ""; }; sub = { text = ""; }; text = ""; "thumb_url" = { text = ""; }; title = { text = "2009-2010"; }; type = { text = "title"; }; }, { id = { text = "76302"; }; sub = { text = "December 3, 2010"; }; text = ""; "thumb_url" = { text = "http://www.puc.edu/__data/assets/image/0019/76303/varieties/thumb.jpg"; }; title = { text = "Christmas Colloquy"; }; type = { text = "gallery"; }; } ) Each section has a type key, which I need to check. When it finds the "title" key, I need to add those to an array. Then the next sections that would use the "gallery" key needs to be in its own array until it finds another "title" key. Then the "gallery" keys after that into their own array. I am using this a UITableView section titles and content. So, the NSDictionary above should have one NSArray *titles; array, and two other arrays each containing the galleries that came after the title. I have tried using a for loop but I just can't seem to get it right. And ideas would be appreciated.

    Read the article

  • OO Objective-C design with XML parsing

    - by brainfsck
    Hi, I need to parse an XML record that represents a QuizQuestion. The "type" attribute tells the type of question. I then need to create an appropriate subclass of QuizQuestion based on the question type. The following code works ([auto]release statements omitted for clarity): QuizQuestion *question = [[QuizQuestion alloc] initWithXMLString:xml]; if( [ [question type] isEqualToString:@"multipleChoiceQuestion"] ) { [myQuestions addObject:[[MultipleChoiceQuizQuestion alloc] initWithXMLString:xml]; } //QuizQuestion.m -(id)initWithXMLString:(NSString*)xml { self.type = ...// parse "type" attribute from xml // parse the rest of the xml } //MultipleChoiceQuizQuestion.m -(id)initWithXMLString:(NSString*)xml { if( self= [super initWithXMLString:xml] ) { // multiple-choice stuff } } Of course, this means that the XML is parsed twice: once to find out the type of QuizQuestion, and once when the appropriate QuizQuestion is initialized. To prevent parsing the XML twice, I tried the following approach: // MultipleChoiceQuizQuestion.m -(id)initWithQuizRecord:(QuizQuestion*)record { self=record; // record has already parsed the "type" and other parameters // multiple-choice stuff } However, this fails due to the "self=record" assignment; whenever the MultipleChoiceQuizQuestion tries to call an instance-method, it tries to call the method on the QuizQuestion class instead. Can someone tell me the correct approach for parsing XML into the appropriate subclass when the parent class needs to be initialized to know which subclass is appropriate?

    Read the article

  • UIAlert View Objective C - Opening app store link

    - by benhowdle89
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"An Alert!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=301349397&amp;amp;amp;amp;mt=8"]];]; [alert show]; [alert release]; I'm trying to display a UIAlertView with one "Ok" button and one "Buy Full Version" button. How can i make the above code work? Thanks

    Read the article

  • Objective C: Which is changed, property or ivar?

    - by Wilhelmsen
    Worrying about duplicates but can not seem to find and answer I can understand in any of the other posts, I just have to ask: When I have in my .h: @interface SecondViewController : UIViewController{ NSString *changeName; } @property (readwrite, retain) NSString *changeName; then in my .m @synthesize changeName; -(IBAction)changeButton:(id)sender{ changeName = @"changed"; } Is it the synthesized property or the instance variable that get changed when I press "changeButton" ?

    Read the article

  • Small gaps in section headers with custom headers - iPhone / Objective-C

    - by zhar
    Hi there! Since I wanted to use the standard section header with a different font size, I just made custom section headers by using an UIImageView with the standard section header as an image. It looks fine at first, but when I scroll the table, there are small gaps below and above the section headers: Since I am not allowed to post images or more than one hyperlink yet, I will have to provide you with one link to those images: Click me! Picture: How it looks like without touching anything Picture: Dragging the table down Picture: Dragging/Scrolling the table up So as you can hopefully see, there is a small empty gap under (2nd pic) and above (3rd pic) the section header. Another thing to mention is, that the standard behaviour of non-custom section headers is, that they don't become transparent when I drag the table down (making the table offset < 0.0). Is there a way to make custom section headers mimic the same behaviour without those annoying gaps? Greetings, Zhar

    Read the article

  • [objective C] IPhone question about UIImageView memory menagement

    - by BQuadra
    Hi, i have a UIImageView of 1024x768 (the room of my game) and other various UIIMageView on it (the object of my game). The iPhone screen is smaller than the room (UIImageView 1024x768) .. i want to understand if the iPhone's system automatically intercepts the graphic elements outside the visible area of Room (the player's view) and unload temporarily (for memory optimization) or i must do this by hand?? thanks

    Read the article

  • Silly Objective-C inheritance problem when using property

    - by Ben Packard
    I've been scratching my head with this for a couple of hours - I haven't used inheritance much. Here I have set up a simple Test B class that inherits from Test A, where an ivar is declared. But I get the compilation error that the variable is undeclared. This only happens when I add the property and synthesize declarations - works fine without them. TestA Header: #import <Cocoa/Cocoa.h> @interface TestA : NSObject { NSString *testString; } @end TestA Implementation is empty: #import "TestA.h" @implementation TestA @end TestB Header: #import <Cocoa/Cocoa.h> #import "TestA.h" @interface TestB : TestA { } @property NSString *testProp; @end TestB Implementation (Error - 'testString' is undeclared) #import "TestB.h" @implementation TestB @synthesize testProp; - (void)testing{ NSLog(@"test ivar is %@", testString); } @end

    Read the article

  • Objective-C method not being called

    - by Matt S.
    It's either because of the fact I'm tired or because I'm doing it wrong, but for some reason I can't get it to call a method. Here's what I'm trying to call: -(void)newHighScore:(int)d Which right now just does an NSLog saying "yea I'm working!" I'm calling it like this: [highscore newHighScore:score]; highscore is what I called the HighScore class in the .h, and score is an int with the score.

    Read the article

  • Objective c key path operators @avg,@max .....

    - by davide
    arr = [[NSMutableArray alloc]init]; [arr addObject:[NSNumber numberWithInt:4]]; [arr addObject:[NSNumber numberWithInt:45]]; [arr addObject:[NSNumber numberWithInt:23]]; [arr addObject:[NSNumber numberWithInt:12]]; NSLog(@"The avg = %@", [arr valueForKeyPath:@"@avg.intValue"]); This code works fine, but why? valueForKeyPath:@"@avg.intValue" is requesting (int) from each NSNumber, but we are outputting a %@ string in the log. If i try to output a decimal %d i get a number that possibly is a pointer to something. Can somebody explain why the integers become NSNumbers when i call the @avg operator?

    Read the article

  • Objective-C Using Accelerometer (iPhone)

    - by Johannes Jensen
    I have a class called MainGame, which is defined like this in my .h: @interface MainGame : Renderer <UIAccelerometerDelegate> Then later in my .m I have this: - (void) accelerometer: (UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceleration { // here I would read values like accelerometer.x NSLog(@"accelerated!!1"); } Am I doing it right? Currently I'm only testing in iPhone simulator, I'm going to buy the apple $99 developer thing soon. It doesn't log "accelerated!!1", but I'm guessing that's because I'm not running it on an actual device yet?

    Read the article

  • sqlite issue using WHERE statement on a varchar field in Objective-C

    - by Geykel
    Hi, I have this sql statement SELECT * FROM Language WHERE LanguageCode=? where LanguageCode is a varchar(2). When I use sqlite3-prepare-v2 on that statement I got SQLITE_ERROR but if I use SELECT * FROM Language WHERE LanguageID=? where LanguageID is the primary key numeric identity field the statement compiles just fine. Is there any issue filtering by a varchar field using WHERE statement? Thanks

    Read the article

  • Working with the Objective-C/Cocoa flat namespace

    - by Stephen Blinkhorn
    I've not found anything that addresses my specific name space question as yet. I am working on some AudioUnit plug-ins featuring Cocoa based GUIs. The plug-ins use a common library of user interface classes (sliders, buttons etc) which are simply added to each Xcode project. When I recompile and distribute updates it is pretty much guaranteed that at least one user interface class will have been updated since the last release. If the user launches an older plug-in before an updated plug-in then the old Cocoa classes are already loaded into the run time and the plug-in attempts to use the older implementations - often resulting in a failure one way or another. I know frameworks are the intended solution but the overhead and backwards compatibility issues are not ideal. I prefix all class names where possible but what options do I have to ensure that each plug-in contains unique class names for the shared user interface classes?

    Read the article

  • Log the method name in objective-C?

    - by vodkhang
    Currently, we are defining ourselves an extended log mechanism to print out the class name and the source line number of the log. #define NCLog(s, ...) NSLog(@"<%@:%d> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) For example, when I call NCLog(@"Hello world"); The output will be: Hello world Now I also want to log out the method name like: Hello world So, this would make our debugging become easier when we can know which method is getting called. I know that we also have XCode debugger but sometimes, I also want to do debugging by logging out.

    Read the article

  • objective-c Novice - Needs help with global variables and setter method

    - by user544006
    I am creating a quiz app which has 2 views, MMAppViewController and a subview Level1View. I have declared NSInteger property "theScore" in the MMAppViewController view and have synthesised it. In my Level1View when they answer a correct question the "theScore" int will increase by one. The score has to be a global variable because when you reach so many points it will unlock the next level. For some reason in my switch statement it only lets me use the setTheScore method once. I am getting errors for every other set method in the switch statement. Error: "Duplicate label setTheScore". The statement is in the pushButtonAnswer method: setTheScore: theScore++; Here is my code: #import "Level1View.h" #import "MMAppViewController.h" @implementation Level1View @synthesize answer; @synthesize question; @synthesize userAnswer; @synthesize theScore; @synthesize score; int questionNum=0; NSInteger score=0; NSInteger theScore; BOOL start=FALSE; BOOL optionNum=FALSE; -(IBAction)pushBack{ [self dismissModalViewControllerAnimated:YES]; } -(IBAction)pushButton1{ optionNum=TRUE; labelAnswer.textColor=[UIColor blackColor]; userAnswer=@"1"; [labelAnswer setText:(@"You chose 'A'")]; } -(IBAction)pushButton2{ optionNum=TRUE; labelAnswer.textColor=[UIColor blackColor]; userAnswer=@"2"; [labelAnswer setText:(@"You chose 'B'")]; } -(IBAction)pushButton3{ optionNum=TRUE; labelAnswer.textColor=[UIColor blackColor]; userAnswer=@"3"; [labelAnswer setText:(@"You chose 'C'")]; } -(IBAction)pushButtonAnswer{ labelAnswer.textColor=[UIColor blackColor]; switch (questionNum){ case 1: if(answer==userAnswer && optionNum==TRUE){ labelAnswer.textColor=[UIColor greenColor]; [labelAnswer setText:(@"correct")]; [self hideButtons]; score++; [self setTheScore: theScore++]; } else if(optionNum==FALSE){ [labelAnswer setText:(@"Please choose an answer below:")];} else{ labelAnswer.textColor=[UIColor redColor]; [labelAnswer setText:(@"wrong")];} [self hideButtons]; break; case 2: if(answer==userAnswer && optionNum==TRUE){ labelAnswer.textColor=[UIColor greenColor]; [labelAnswer setText:(@"correct")]; [self hideButtons]; score++; [self setTheScore: theScore++]; } else if(optionNum==FALSE){ [labelAnswer setText:(@"Please choose an answer below:")];} else{ labelAnswer.textColor=[UIColor redColor]; [labelAnswer setText:(@"wrong")]; [self hideButtons];} break; case 3: if(answer==userAnswer && optionNum==TRUE){ labelAnswer.textColor=[UIColor greenColor]; .... And #import "MMAppViewController.h" #import "Level1View.h" @implementation MMAppViewController @synthesize theScore; NSInteger score; -(IBAction)pushLevel1{ Level1View *level1View = [[Level1View alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:level1View animated:YES]; theScore++; } -(IBAction)pushLevel2{ //Level1View *level1View = [[Level1View alloc] initWithNibName:nil bundle:nil]; //[self presentModalViewController:level1View animated:YES]; NSInteger *temp = Level1View.score; //int theScore=2; [labelChoose setText:[NSString stringWithFormat:@"You scored %i", theScore]]; } Does anyone know why i am getting these errors and if I am coding this correctly?

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >