Reputation: 9
So I'm looking around stack overflow, I see a lot of these unrecognized selector sent to instance error messages. Some ARC related, most non ARC related. What I essentially I am doing is calling a NSTimer to call a method every 6 seconds to change the file path of the array for a photo. (An automated banner if you will.) When 6 seconds has passed, I get this error message:
2014-07-10 11:04:35.152 ysysy[435:57924] -[TableViewController animateFunction]: unrecognized selector sent to instance 0x156989f0
2014-07-10 11:04:35.154 ysysy[435:57924] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TableViewController animateFunction]: unrecognized selector sent to instance 0x156989f0'
I call a setBannerTimer method inside of the viewWllAppearMethod:
[self performSelectorOnMainThread:@selector(setBannerTimer) withObject:nil waitUntilDone:NO];
setBannerTimer then triggers a string method called animate function every 6 seconds:
- (void) setBannerTimer {
self->bannerTimer = [NSTimer scheduledTimerWithTimeInterval:6 target:self selector:@selector(animateFunction) userInfo:nil repeats:YES];
}
Animatie function:
+(NSString *)animateFunction
return photoPath;
}
Hopefully I laid my problem out for everyone to easily understand. I must be doing something syntactically wrong with my method right? I am so close! Thanks ahead of time!
Upvotes: 0
Views: 813
Reputation: 1866
It's not about ARC, scheduledTimerWithTimeInterval:target:selector:userInfo:repeats should have an instance method selector, not a class method one;
=> Call a
- (NSString *)animateFunction
instead of a
+ (NSString *)animateFunction
Upvotes: 2