Hou*_*man 1 nsnotificationcenter ios ios7
我在选择通知方法时遇到问题.
在init中我已经定义了这个:
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(stopSyncIndicator:) name:IOS_STOP_SYNC_INDICATOR object:nil];
Run Code Online (Sandbox Code Playgroud)
不过,在头文件和相同的实现中都定义了该方法:
-(void)stopSyncIndicator
{
[indicator stopAnimating];
}
Run Code Online (Sandbox Code Playgroud)
但是,当其他班级发布此通知时:
NSNotification *note = [NSNotification notificationWithName:IOS_STOP_SYNC_INDICATOR object:nil];
[[NSNotificationCenter defaultCenter] postNotification:note];
Run Code Online (Sandbox Code Playgroud)
地狱破裂了:
[FTRecordViewController stopSyncIndicator:]: unrecognized selector sent to instance 0x8d3bc00
2013-11-18 13:47:06.994 [1835:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FTRecordViewController stopSyncIndicator:]: unrecognized selector sent to instance 0x8d3bc00'
*** First throw call stack:
(
0 CoreFoundation 0x01bf75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018f88b6 objc_exception_throw + 44
2 CoreFoundation 0x01c94903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
Run Code Online (Sandbox Code Playgroud)
知道这里发生了什么吗?
您的选择器:指示它将接受参数,您的实现不会
或
@selector(stopSyncIndicator) //no :
Run Code Online (Sandbox Code Playgroud)
要么
-(void)stopSyncIndicator:(NSNotification *)notification //accept argument
Run Code Online (Sandbox Code Playgroud)
会解决这个问题
| 归档时间: |
|
| 查看次数: |
955 次 |
| 最近记录: |