[英]Why am I getting an “unrecognised selector sent to instance” error when I have defined the method?
I'm building an iOS (5.1) app on Xcode (4.4.1), and I'm almost done with the first phase of development, but I'm stuck on the final line of code. 我正在Xcode(4.4.1)上构建一个iOS(5.1)应用程序,开发的第一阶段几乎完成,但是我被困在最后一行代码上。 I've been using Kumulos as a backend & API solution, and at the moment all the API is working fine except for this bit:
我一直在使用Kumulos作为后端和API解决方案,目前除了以下几点,所有API都工作正常:
Kumulos* k = [[Kumulos alloc]init];
[k setDelegate:self];
[k createNewTimePointWithJourneyIDFK:[journeyID integerValue]
andTime:currentDate andLat:[lat floatValue] andLon:[lon floatValue]];
When it hits the createNewTimePointWithJourneyIDFK: method, it terminates. 当它到达createNewTimePointWithJourneyIDFK:方法时,它终止。 In the log it mentions this method and says an unrecognised selector was sent to an instance.
它在日志中提到了此方法,并说一个无法识别的选择器已发送到实例。
Now I realise this question has been asked a million times on SO, but I've 1) checked that the method has been defined, and 2) that it has been called correctly (or at least to the best of my knowledge). 现在,我意识到这个问题已在SO上被问了一百万遍了,但是我已经(1)检查了该方法是否已定义,以及2)已经正确调用了该方法(或至少据我所知)。 The way I've done the above is the way I've done the rest of the API calls, and they work well, so I can't see what the problem is.
我完成上述操作的方式就是我完成了其余API调用的方式,并且它们运行良好,因此我看不出问题出在哪里。 Very frustrating, I've spent hours on this last line!
非常沮丧,我在最后一行上花了几个小时! So please don't think I've come hear after a few minutes of not knowing what to do.
因此,请不要以为几分钟后不知道该怎么做,我就没再听到我的消息了。
The error message 错误讯息
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)
The Method 方法
This is located in the Kumulos.m file. 该文件位于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;
}
The only thing I can think of is that something got stale in your project. 我唯一能想到的是项目中有些陈旧。 Have you tried cleaning (via Product → Clean ) and rebuilding?
您是否尝试过清洁(通过Product → Clean )和重建?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.