我对函数
进行了以下调用 [[LocationDictionary sharedLocationDictionary] getLocation:[NSDate date]]
我将此代码段放在我的app委托和其他任何地方,它工作得很好..但是当我把它放在
块中时- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
它直接崩溃,出现以下错误:
-[NSCFString objectForIntervalOf:]: unrecognized selector sent to instance 0x5e0b910
2011-04-06 16:42:56.668 SmarTrek[57331:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectForIntervalOf:]: unrecognized selector sent to instance 0x5e0b910'
*** Call stack at first throw:
即使我这样做:
[[LocationDictionary sharedLocationDictionary] getLocation:[NSDate date]];
并改变:
- (id) getLocation:(NSDate *) date
{
return [locationDic objectForIntervalOf:date];
}
- (id)objectForIntervalOf:(id)object {
return nil;
}
使用NSZombie我得到了:
*** -[IntervalDictionary objectForIntervalOf:]: message sent to deallocated instance 0x5e23930
Current language: auto; currently objective-c
2011-04-06 19:51:43.595 Project[62298:207] *** NSInvocation: warning: object 0x5e23930 of class '_NSZombie_IntervalDictionary' does not implement methodSignatureForSelector: -- trouble ahead
2011-04-06 19:51:43.595 Project[62298:207] *** NSInvocation: warning: object 0x5e23930 of class '_NSZombie_IntervalDictionary' does not implement doesNotRecognizeSelector: -- abort
我该如何解决这个问题?
答案 0 :(得分:0)
看起来您正在将objectForIntervalOf消息发送到NSString。由于NSString没有响应该消息,因此您将获得异常。
我们需要查看使用objectForIntervalOf的代码。
答案 1 :(得分:0)
看起来你有一些内存问题(很可能是一个对象过早地被解除分配)。 NSZombieEnabled和Clang分析仪可能有所帮助。