1
我都设置一个计时器,重置对象的属性支持一个已知的选择:iPhone对象已经不上NSTimed呼叫
- (IBAction)open:(id)sender {
int viewID = ((UIButton*)sender).tag;
for (int i=0; i<[self.webViews count]; i++) {
WebViewController* page = [self.webViews objectAtIndex:i];
if (page.loadFinished == NO) {
[page.webView stopLoading];
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(setLoadingNotFinished:) userInfo:page repeats:NO];
}
}
- (void) setLoadingNotFinished:(WebViewController*)page {
page.loadFinished = NO;
}
当进入setLoadingNotFinished方法,我有这样的崩溃:
2011-04-25 04:34:22.358 MyApp[7823:207] -[__NSCFTimer setLoadFinished:]: unrecognized selector sent to instance 0x4b203d0
2011-04-25 04:34:22.360 MyApp[7823:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFTimer setLoadFinished:]: unrecognized selector sent to instance 0x4b203d0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dca5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f1e313 objc_exception_throw + 44
2 CoreFoundation 0x00dcc0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d3b966 ___forwarding___ + 966
4 CoreFoundation 0x00d3b522 _CF_forwarding_prep_0 + 50
5 MyApp 0x00003a42 -[MainGridController setLoadingNotFinished:] + 66
6 Foundation 0x007ba749 __NSFireTimer + 125
7 CoreFoundation 0x00dab8c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
8 CoreFoundation 0x00dace74 __CFRunLoopDoTimer + 1220
9 CoreFoundation 0x00d092c9 __CFRunLoopRun + 1817
10 CoreFoundation 0x00d08840 CFRunLoopRunSpecific + 208
11 CoreFoundation 0x00d08761 CFRunLoopRunInMode + 97
12 GraphicsServices 0x010021c4 GSEventRunModal + 217
13 GraphicsServices 0x01002289 GSEventRun + 115
14 UIKit 0x0002ac93 UIApplicationMain + 1160
15 MyApp 0x000027e9 main + 121
16 MyApp 0x00002765 start + 53
)
terminate called after throwing an instance of 'NSException'
为什么会发生这种事故?
我不明白为什么它没有找到选择器。
的loadFinished属性设置,甚至在这个属性的第一次测试调用的NSTimer方法之前的作品,我在很多地方使用这个属性。
页面在定时方法中不是零。
self.webViews是一个保留的NSMutableArray。
请注意,我在我的代码纠正语法错误。它现在是正确的,但如果你使用的原始帖子是错误的。 – 2011-04-25 01:23:20