gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 20:31:45 27 4
gpt4 key购买 nike

我正在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com