Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 发送到自定义类实例的选择器无法识别_Objective C_Xcode - Fatal编程技术网

Objective c 发送到自定义类实例的选择器无法识别

Objective c 发送到自定义类实例的选择器无法识别,objective-c,xcode,Objective C,Xcode,下面是类标题: @interface ChallengeItem : NSObject ....... - (NSString *) getAlertIntervalInString; - (void) createReminder; @end some implementation in .m file: - (NSString *) getAlertIntervalInString { ... do something } - (void)createReminder { ...

下面是类标题:

@interface ChallengeItem : NSObject 
.......
- (NSString *) getAlertIntervalInString;
- (void) createReminder;

@end

some implementation in .m file:

- (NSString *) getAlertIntervalInString {
... do something
}

- (void)createReminder {
... do something
}
我打电话

for (int i = 0; i < [self count]; i++) {
    ChallengeItem *currentItem = [self getChallengeAtIndex:i];
    if (currentItem.isStarted) {
        [currentItem createReminder];
    }
}

没有出现错误。 有什么问题

这是控制台日志

当前语言:自动;当前目标-c 2011-11-23 00:56:40.056 30天挑战[379:12b03]-[ChallengeItem createReminder]:
已将无法识别的选择器发送到实例0x6079900 2011-11-23 00:56:40.147 30天挑战[379:12b03]*由于以下原因终止应用程序 未捕获异常“NSInvalidArgumentException”,原因: '-[ChallengeItem createReminder]:无法识别的选择器已发送到 实例0x6079900' *第一次抛出时调用堆栈:


我看不出你的代码有任何明显的问题。为了确保
getChallengeAtIndex
实际上正在返回
ChallengeItem
实例,您可以在该行设置断点并检查返回的值。

安装新版本的XCode后,问题将消失。

我们可以从控制台查看实际的崩溃日志吗?显示getChallengeAtIndex的代码-(ChallengeItem*)getChallengeAtIndex:(NSInteger)index{return[self.challenges objectAtIndex:index];}我会检查它,getChallengeAtIndex返回正常实例。如果我将函数createReminder更改为一些已经实现的函数,它会工作,但如果我调用createReminder或向类添加新函数,它会导致错误:(
[currentItem createReminder]; 
[currentItem getAlertIntervalInString];
(
    0   CoreFoundation                      0x00fb35a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x01107313 objc_exception_throw + 44
    2   CoreFoundation                      0x00fb50bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00f24966 ___forwarding___ + 966
    4   CoreFoundation                      0x00f24522 _CF_forwarding_prep_0 + 50
    5   30 Day Challenge                    0x00006950 -[ChallengeCollection setRemindersForStartedChallenges] + 144
    6   30 Day Challenge                    0x00002f27 -[_0_Day_ChallengeAppDelegate applicationDidEnterBackground:] + 151
    7   UIKit                               0x00209a40 -[UIApplication _handleApplicationSuspend:eventInfo:] + 607
    8   UIKit                               0x00213039 -[UIApplication handleEvent:withNewEvent:] + 4127
    9   UIKit                               0x0020aabf -[UIApplication sendEvent:] + 71
    10  UIKit                               0x0020ff2e _UIApplicationHandleEvent + 7576
    11  GraphicsServices                    0x01712992 PurpleEventCallback + 1550
    12  CoreFoundation                      0x00f94944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    13  CoreFoundation                      0x00ef4cf7 __CFRunLoopDoSource1 + 215
    14  CoreFoundation                      0x00ef1f83 __CFRunLoopRun + 979
    15  CoreFoundation                      0x00ef1840 CFRunLoopRunSpecific + 208
    16  CoreFoundation                      0x00ef1761 CFRunLoopRunInMode + 97
    17  GraphicsServices                    0x017111c4 GSEventRunModal + 217
    18  GraphicsServices                    0x01711289 GSEventRun + 115
    19  UIKit                               0x00213c93 UIApplicationMain + 1160
    20  30 Day Challenge                    0x00002059 main + 121
    21  30 Day Challenge                    0x00001fd5 start + 53
    22  ???                                 0x00000001 0x0 + 1
)
terminate called throwing an exception(gdb)