2010-12-08 3 views
1

IOS3에서 잘 실행되는 iPad 앱은 IOS4.2에서 실패합니다. 작업 대기열에서 http 세션을 실행하는 클래스가 있으며 실패는이 활동에 연결됩니다.IOS4.2 앱이 EXC_BAD_ACCESS와 함께 종료됩니다.

Program received signal: “EXC_BAD_ACCESS”. 
[Switching to thread 11523] 

내가 코드에서 NSLog 문을 넣고 로컬 변수가 변경 될 때 충돌이 발생하는 것을 발견되었다, 그래서 아무것도 공개하지 않았다 활성화 NSZombies 실행 다음은 콘솔 출력됩니다. 여기

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] 

그것은 읽기 전용 (그것의 속성은 원자와 READWRITE로 선언)이되었다 상태처럼 다음 코드 섹션입니다.

다른 관련 정보는 하위보기가 방금 변경되었으며 위의 루틴에서 호출을 트리거한다는 것입니다. 코드 :

//Start the update  
UCiEnablerAppDelegate *controller = (UCiEnablerAppDelegate *)[[UIApplication sharedApplication] delegate]; 
[controller deduceIEnablerServiceAccess]; 
controller.serviceBusy = TRUE; //1.04 

누구나 이런 사람이 보입니까?

아이디어가있는 곳은 어디입니까? NSOperations를 시작할 때 아이폰 OS 4.2

#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:] 
+0

** 향후 ** 귀하의 질문을 검토하여 코드 형식이 올바른지 확인하십시오. – JeremyP

+0

또한 디버거에서 실행하여 스택 추적을 가져 와서 여기에 게시하십시오. – JeremyP

+0

충돌을 일으키는 상태에 대한 맞춤 설정 도구가 없을 가능성이 있습니까? 해당 줄에 중단 점을 설정하고 self.status = IEnablerServiceUpdating 단계를 수행하면 어떻게됩니까? – Rog

답변

0

NSOperationQueue 지금 GrandCentralDispatch를 사용

감사 로빈

여기에 스택 추적입니다. There's a Technical Q&A here

isConcurrent 속성에 관계없이 새 스레드에서 대기열이 이제 NSOperation 하위 클래스의 start 메서드를 호출합니다. 내 경험에 의하면 start 메서드 내에서 NSURLConnection을 사용하는 경우 start 스레드가 실행 중일 때 NSRunLoop이 없으므로 코드가 더 이상 실행되지 않습니다.

Apple은 어쨌든 start 메서드로 새 스레드를 생성해야하기 때문에이 변경으로 호환성이 깨지지 않는다고 말합니다.

하위 호환성을 위해 서브 클래스를 start에서 run으로 변경해야합니다.

+0

GCD에 대한 연구에 따르면 조작 대기열이 아닌 디스패치 대기열 (동시성 안내서 p13)에 적합하다는 것이 나와 있습니다. 그러나 NSURLConnections 작업 큐에서 실행해야합니다. 하지만 iOS3 이후로 이러한 API를 호출하는 더 좋은 방법은 비동기 API 호출을 사용하는 것입니다. 그러나 코드를 완전히 테스트하기 위해 환경에 액세스 할 수 없으므로 코드를 수정하기를 꺼리고/할 수 없습니다. Arrghghhhh! –