2012-08-11 60 views
0

我在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:方法,它終止。在日誌中它提到了這種方法,並說一個無法識別的選擇器被髮送到一個實例。

現在我意識到這個問題已經被提出了一百萬次,但是我已經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; 
} 
+0

請顯示實際的錯誤信息。我懷疑問題出在圖書館本身。 – 2012-08-11 12:52:37

+0

你能粘貼確切的錯誤信息嗎? – sergio 2012-08-11 12:52:46

+0

道歉,它現在被添加。 – andrewb 2012-08-11 12:56:25

回答

3

我能想到的唯一的事情就是你的項目中有些東西是陳舊的。您是否嘗試過清洗(通過產品清潔)和重建?

+0

「清潔和重建」是什麼意思?我只是嘗試退出Xcode,關閉我iPhone上的所有內容並重新啓動它,但沒有成功。 – andrewb 2012-08-11 13:12:51

+1

我認爲他的意思是進入「產品菜單>清潔」,然後再次運行。 – jhilgert00 2012-08-11 13:27:29

+0

也可能在模擬器中「重置內容和設置」。清潔時我通常都會這樣做。 – jhilgert00 2012-08-11 13:29:36

相關問題