Objective c IOS4.2应用程序退出,EXC\u访问错误

Objective c IOS4.2应用程序退出,EXC\u访问错误,objective-c,nsoperationqueue,ios-4.2,Objective C,Nsoperationqueue,Ios 4.2,在IOS3下运行良好的iPad应用程序在IOS4.2下失败。它有一个类,该类从操作队列运行http会话,失败与此活动有关。以下是控制台输出: Program received signal: “EXC_BAD_ACCESS”. [Switching to thread 11523] 运行NSZombies enabled并没有透露任何信息,所以我在代码中加入了NSLog语句,发现当局部变量发生更改时会发生崩溃。以下是代码部分: self.currentOperation = [[[Deduc

在IOS3下运行良好的iPad应用程序在IOS4.2下失败。它有一个类,该类从操作队列运行http会话,失败与此活动有关。以下是控制台输出:

Program received signal:  “EXC_BAD_ACCESS”.
[Switching to thread 11523]
运行NSZombies enabled并没有透露任何信息,所以我在代码中加入了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]
这就像状态变成了只读(它的属性声明为原子和读写)

另一条相关信息是,一个子视图刚刚被更改,它触发了对上述例程的调用。它的代码是:

//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:]

iOS 4.2中的
NSOperationQueue
现在在启动
NSOperations
时使用GrandCentralDispatch

现在,不管
isConcurrent
属性如何,队列都会在新线程中调用
NSOperation
子类的
start
方法。根据我的经验,这意味着如果在
start
方法中使用
NSURLConnection
,您的代码将不再运行,因为运行的线程
start
没有
nsrunlop

苹果公司表示,这一改变不会破坏兼容性,因为你本来应该在
start
方法中生成一个新线程


为了向后兼容,您应该将子类从使用
start
更改为使用
run

,以后请检查您的问题,确保代码格式正确。此外,请在调试器中运行此操作,获取堆栈跟踪并将其发布到此处。您是否有导致崩溃的自定义状态设置程序?如果在该行上设置断点并进入self.status=IEnablerServiceUpdating,会发生什么情况?@Rog:可能是。我认为某些KVO被绊倒了,这就是为什么我希望看到堆栈跟踪。我对GCD的研究表明,它适用于调度队列(并发指南p13),而不是操作队列。但是NSURLConnections应该从操作队列运行。但是由于iOS3,调用这些函数的更好方法是通过异步API调用。但是我不愿意/无法修改代码,因为我无法访问环境来全面测试它。啊!