0

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!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user3817163
  • 9
  • 1
  • 7
  • 2
    Uh, you've declared `animateFunction` as a class method, yet the timer function expects an instance method. – Hot Licks Jul 10 '14 at 16:24
  • Try with `-(NSString *)animateFunction` instead of ` +(NSString *)animateFunction`, you're calling a class method. – Larme Jul 10 '14 at 16:24
  • Dude, I seriously think you need to start over with iOS development. I see bad design everywhere. – duci9y Jul 10 '14 at 16:25
  • @duci9y hah! Yeah still learning this lingo. I agree with you, Java is more my native language. – user3817163 Jul 10 '14 at 16:27
  • Possible duplicate of [How can I debug 'unrecognized selector sent to instance' error](https://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error) – Cœur Jul 08 '19 at 05:52

1 Answers1

2

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
Jerome Diaz
  • 1,746
  • 8
  • 15