【发布时间】:2010-12-08 08:44:08
【问题描述】:
在 IOS3 下运行良好的 iPad 应用程序在 IOS4.2 下失败。它有一个从操作队列运行 http 会话的类,并且失败与此活动相关联。这是控制台输出:
Program received signal: “EXC_BAD_ACCESS”.
[Switching to thread 11523]
运行 NSZombies 启用并没有显示任何内容,因此我一直将 NSLog 语句放入代码中,发现当局部变量更改时会发生崩溃。这是代码部分:
self.currentOperation = [[[DeduceAccessOperation alloc] init] autorelease];
[self.currentOperation addObserver:self forKeyPath:@"isFinished"
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:NULL];
NSLog (@"Start observer added");
[operationQueue addOperation:self.currentOperation];
NSLog (@"Start operation added");
NSLog(@"State is %d", self.status);
self.status = IEnablerServiceUpdating;
NSLog (@"State updated");
这是控制台日志输出:
2010-12-08 21:26:44.548 UCiEnabler[5180:307] Start observer added
2010-12-08 21:26:44.550 UCiEnabler[5180:307] Start operation added
2010-12-08 21:26:44.552 UCiEnabler[5180:307] State is 1
Program received signal: “EXC_BAD_ACCESS”.
[Switching to thread 11523]
就像 status 变成了只读的(它的属性被声明为 atomic 和 readwrite)。
另一条相关信息是子视图刚刚被更改,它触发了对上述例程的调用。它的代码是:
//Start the update
UCiEnablerAppDelegate *controller = (UCiEnablerAppDelegate *)[[UIApplication sharedApplication] delegate];
[controller deduceIEnablerServiceAccess];
controller.serviceBusy = TRUE; //1.04
有人见过这样的吗?
有人知道下一步该去哪里吗?
问候 罗宾
这是堆栈跟踪:
#0 0x34a80464 in objc_msgSend
#1 0x3119543e in NSKVOPendingNotificationCreate
#2 0x3119535a in NSKeyValuePushPendingNotificationPerThread
#3 0x3117009a in NSKeyValueWillChange
#4 0x311682c6 in -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:]
#5 0x311cc718 in _NSSetIntValueAndNotify
#6 0x000097ce in -[IEnablerService startDeducingAccessState] at IEnablerService.m:55
#7 0x00002bc0 in -[UCiEnablerAppDelegate deduceIEnablerServiceAccess] at UCiEnablerAppDelegate.m:100
#8 0x0000a33e in -[RootViewControlleriPad animationDidStop:finished:context:] at RootViewController-iPad.m:43
#9 0x341bb336 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
【问题讨论】:
-
以后请检查您的问题以确保代码格式正确。
-
另外,在调试器中运行它,获取堆栈跟踪并在此处发布。
-
没有机会为导致崩溃的状态自定义设置器?如果在该行设置断点并进入 self.status = IEnablerServiceUpdating 会发生什么?
-
@Rog:可能是。我在想一些 KVO 被绊倒了,这就是为什么我想查看堆栈跟踪。
标签: objective-c nsoperationqueue ios-4.2