I’m using a NSTimer to run an animation (for now just call it myMethod). However, its causing a crash.
Here’s the code:
@implementation SecondViewController
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void) myMethod
{
NSLog(@"Mark Timer Fire");
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"We've loaded scan");
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(myMethod:)
userInfo:nil
repeats:YES];
animationTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target:self selector:@selector(myMethod:) userInfo:nil repeats: YES];
}
And here’s the output during the crash
-[SecondViewController myMethod:]: unrecognized selector sent to instance 0x4b2ca40
2012-06-21 12:19:53.297 Lie Detector[38912:207] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[SecondViewController myMethod:]: unrecognized selector sent to instance 0x4b2ca40’
So what am I doing wrong here?
either you can use only
or you can do (remove : from both the method name)..
hope this will help you