简体   繁体   English

无法识别的选择器已发送到实例

[英]unrecognized selector sent to instance

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. 某些与ARC相关,大多数与ARC不相关。 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. 我基本上在做什么,就是每6秒钟调用一次NSTimer调用一个方法来更改照片数组的文件路径。 (An automated banner if you will.) When 6 seconds has passed, I get this error message: (如果愿意,可以使用自动横幅广告。)经过6秒后,我收到以下错误消息:

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: 我在viewWllAppearMethod内部调用setBannerTimer方法:

[self performSelectorOnMainThread:@selector(setBannerTimer) withObject:nil waitUntilDone:NO];

setBannerTimer then triggers a string method called animate function every 6 seconds: 然后,setBannerTimer每6秒触发一次称为animate函数的字符串方法:

- (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! 提前谢谢!

It's not about ARC, scheduledTimerWithTimeInterval:target:selector:userInfo:repeats should have an instance method selector, not a class method one; 与ARC无关,chedchedTimerWithTimeInterval:target:selector:userInfo:repeats应该具有实例方法选择器, 而不是类方法选择器;

=> Call a =>叫一个

- (NSString *)animateFunction

instead of a 代替

+ (NSString *)animateFunction

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM