iphone - 为什么在定义方法后会出现 "unrecognised selector sent to instance"错误?

标签 iphone ios xcode unrecognized-selector

我正在 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;
}

最佳答案

我唯一能想到的是您的项目中有些东西已经过时了。您是否尝试过清洁(通过产品清洁)和重建?

关于iphone - 为什么在定义方法后会出现 "unrecognised selector sent to instance"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11914851/

相关文章:

iphone - 方向键盘移动

ios - 使用prefersStatusBarHidden而不丢失默认状态栏可见性行为(在垂直紧凑环境中隐藏状态栏)

ios - dismissViewControllerAnimated 自定义动画

ios - 在 ViewController 中创建数组的预期声明错误,无法找出原因

ios - Xcode - CorePlot 代码链接器命令错误

ios - 应用内购买订阅

ios - 点击特定标记如何获取标题名称

objective-c - 我应该从 Apple 的 Core Data Utility 教程中获得什么值?

ios - 需要将 firebase 远程配置中的值更新到我的 plist

ios - Swift iOS - 如何将计时器放在 Firebase TransactionBlock 上以防止它在特定时间段内增加