I am developing an iphone application where you log in a server and after you get validation my app moves you to another viewcontroller where you can use a button to send your gps location. For some reason when I press a button in my next viewcontroller I get this error :
Administrator[3148:c07] -[UIViewController SendGPS:]: unrecognized selector sent to instance 0x88b58d0
2013-01-08 16:01:21.662 Administrator[3148:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController SendGPS:]: unrecognized selector sent to instance 0x88b58d0'
If I apply my gps code-buttons in a single viewcontroller it turns out to work fine but when I use my app with the two viewcontrollers when the first one redirects you to the second one (if only you log in to the server) I get this mistake.I move to the second viewcontroller through a condition where I check the response from the server. This is the code which i use to change viewcontrollers :
NSString *compare = [NSString stringWithFormat:@"true"];
if ( [compare isEqualToString:string]) {
UIViewController* FourthViewController = [[UIViewController alloc] initWithNibName:@"FourthViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:FourthViewController.view]; }
else
NSLog(@"validation not complete");
and this is my button where i use an NSTimer:
-(IBAction)SendGPS:(id)sender
{
Timer= [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(requestIt) userInfo:nil repeats:YES];
}
Any thoughts? thanks in advance!
The incorrect part of your code is obvious, this is how you initialize your view controller:
And that is creating a new view controller object, fresh from Apple’s code, that has no Chuck Norris’ idea what the method
SendGPS:is. Because you obviously created a new view controller subclass called ‘FourthViewController‘ that implementsSendGPS:in your Xcode project. You are creating an instance called ‘FourthViewController‘ but it doesn’t actually point to that class, its aUIViewControllerclass as you specified.The correct code should be:
You really need to figure it out, I don’t think you understand Objective-C, pick up a book, get reading, and do it right!