下面的實例類的頭:無法識別的選擇發送到定製類
@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];
}
}
,並收到一個無法識別的選擇錯誤,但是當我改變
[currentItem createReminder];
到
[currentItem getAlertIntervalInString];
錯誤未出現。 問題是什麼?
這裏是控制檯日誌
當前語言:汽車;當前objective-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' *調用堆棧在第一擲:
(
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)
我們可以從控制檯看到實際的崩潰日誌嗎? –
顯示代碼getChallengeAtIndex – tiltem
- (ChallengeItem *)getChallengeAtIndex:(NSInteger)index { \t return [self.challenges objectAtIndex:index]; } –