我有以下的函数的调用如何处理BAD_EXEC在代码
[[LocationDictionary sharedLocationDictionary] getLocation:[NSDate date]]
我把这个代码片段在我的应用程序委托和其他地方一样,它工作得很好。但是当我把它里面的的
- (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
我该如何解决这个问题?
查看我的更新 – aherlambang 2011-04-06 23:57:32
您正在做出一个大的假设,这是导致问题的唯一方法调用。至少,使用调试器,打破异常并找出它的中断点。但严重的是,NSZombieEnabled正是为这种事情而设计的。 – 2011-04-07 00:00:03
你是对的,一个对象被释放得太早,但是哪一个呢? – aherlambang 2011-04-07 02:56:22