繁体   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