簡體   English   中英

定義方法后,為什么會收到“無法識別的選擇器發送到實例”錯誤?

[英]Why am I getting an “unrecognised selector sent to instance” error when I have defined the method?

我正在Xcode(4.4.1)上構建一個iOS(5.1)應用程序,開發的第一階段幾乎完成,但是我被困在最后一行代碼上。 我一直在使用Kumulos作為后端和API解決方案,目前除了以下幾點,所有API都工作正常:

Kumulos* k = [[Kumulos alloc]init];
[k setDelegate:self];
[k createNewTimePointWithJourneyIDFK:[journeyID integerValue]
    andTime:currentDate andLat:[lat floatValue] andLon:[lon floatValue]];

當它到達createNewTimePointWithJourneyIDFK:方法時,它終止。 它在日志中提到了此方法,並說一個無法識別的選擇器已發送到實例。

現在,我意識到這個問題已在SO上被問了一百萬遍了,但是我已經(1)檢查了該方法是否已定義,以及2)已經正確調用了該方法(或至少據我所知)。 我完成上述操作的方式就是我完成了其余API調用的方式,並且它們運行良好,因此我看不出問題出在哪里。 非常沮喪,我在最后一行上花了幾個小時! 因此,請不要以為幾分鍾后不知道該怎么做,我就沒再聽到我的消息了。

錯誤訊息

2012-08-11 22:36:58.769 busApp4Kumulos[5485:707] -[Kumulos
createNewTimePointWithJourneyIDFK:andTime:andLat:andLon:]:
unrecognizedselector sent to instance 0x3d1b70 2012-08-11 22:36:58.778
busApp4Kumulos[5485:707]
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[Kumulos
createNewTimePointWithJourneyIDFK:andTime:andLat:andLon:]:
unrecognized selector sent to instance 0x3d1b70'
*** First throw call stack:
(0x35add88f 0x37e84259 0x35ae0a9b 0x35adf915 0x35a3a650 0x3ef5
0x37f86de3 0x37f86785 0x37f80e3f 0x35ab1b01 0x35ab112f 0x35ab0351
0x35a334a5 0x35a3336d 0x376cf439 0x3353fcd5 0x2dd9 0x2d74)
terminate called throwing an exception(lldb) 

方法

該文件位於Kumulos.m文件中。

-(KSAPIOperation*) createNewTimePointWithJourneyIDFK:(NSInteger)journeyIDFK
     andTime:(NSDate*)time andLat:(float)lat andLon:(float)lon{

 NSMutableDictionary* theParams = [[NSMutableDictionary alloc]init];
        [theParams setValue:[NSNumber numberWithInt:journeyIDFK] forKey:@"journeyIDFK"];
                [theParams setValue:time forKey:@"time"];
                [theParams setValue:[NSNumber numberWithFloat:lat] forKey:@"lat"];
                [theParams setValue:[NSNumber numberWithFloat:lon] forKey:@"lon"];

KSAPIOperation* newOp = [[KSAPIOperation alloc]initWithAPIKey:theAPIKey
     andSecretKey:theSecretKey andMethodName:@"createNewTimePoint"
     andParams:theParams];
[newOp setDelegate:self];
[newOp setUseSSL:useSSL];

//we pass the method signature for the kumulosProxy callback on this thread

[newOp setCallbackSelector:@selector( kumulosAPI: apiOperation: createNewTimePointDidCompleteWithResult:)];
[newOp setSuccessCallbackMethodSignature:[self methodSignatureForSelector:@selector(apiOperation: didCompleteWithResult:)]];
[newOp setErrorCallbackMethodSignature:[self methodSignatureForSelector:@selector(apiOperation: didFailWithError:)]];
[opQueue addOperation:newOp];

return newOp;
}

我唯一能想到的是項目中有些陳舊。 您是否嘗試過清潔(通過ProductClean )和重建?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM