2013-11-18 2 views
1

У меня проблема с выбором метода для уведомления.непризнанный селектор, отправленный экземпляру

В INIT я определяемое это:

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 
[nc addObserver:self selector:@selector(stopSyncIndicator:) name:IOS_STOP_SYNC_INDICATOR object:nil]; 

Метод определяемый хотя, как в заголовке и тот же реализация:

-(void)stopSyncIndicator 
{ 
    [indicator stopAnimating]; 
} 

Однако, когда другой класс регистрация этого уведомления:

NSNotification *note = [NSNotification notificationWithName:IOS_STOP_SYNC_INDICATOR object:nil]; 
[[NSNotificationCenter defaultCenter] postNotification:note]; 

Ад разрывается:

[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 

Любая идея, что здесь происходит?

ответ

6

Ваш селектор имеет : указав, что он будет принимать аргумент, ваша реализация не

либо

@selector(stopSyncIndicator) //no : 

или

-(void)stopSyncIndicator:(NSNotification *)notification //accept argument 

бы исправить эту

2

Вы хотите сказать, что селектор наблюдателя имеет параметр:

[nc addObserver:self selector:@selector(stopSyncIndicator:) name:IOS_STOP_SYNC_INDICATOR object:nil];`<br/> 

и ваш селектор не имеет параметр:

-(void)stopSyncIndicator 

Чтобы исправить, либо удалить : из selector:@selector(stopSyncIndicator:) или установить метод подписи:

-(void)stopSyncIndicator:(NSNotification *)notification 
Смежные вопросы