gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:25:58 24 4
gpt4 key购买 nike

我在选择通知方法时遇到问题。

在初始化中,我已经定义了这个:

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

但是,该方法在 header 和相同的实现中都已定义:
-(void)stopSyncIndicator
{
[indicator stopAnimating];
}

但是,当另一个类(class)发布此通知时:
NSNotification *note = [NSNotification notificationWithName:IOS_STOP_SYNC_INDICATOR object:nil];
[[NSNotificationCenter defaultCenter] postNotification:note];

hell 爆发:
[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

知道这里发生了什么吗?

最佳答案

您的选择器有 :表明它将接受一个参数,你的实现不

任何一个

@selector(stopSyncIndicator) //no :

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

会解决这个问题

关于ios - 无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20049525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com