2012-10-30 3 views
1

내 주소록 앱이 시뮬레이터에서 정상적으로 작동합니다. 연락처 추가 기능이 있습니다. 장치 (IOS 6)에서 다음 메시지와 함께 오류가 발생합니다.기기에서 응용 프로그램이 충돌하지만 시뮬레이터에서 정상적으로 작동합니다.

그 후
ContactPro[837] has active assertions beyond permitted time: 
{(
<BKProcessAssertion: 0x1f5a28a0> identifier: Suspending process: ContactPro[837] permittedBackgroundDuration: 10.000000 reason: suspend owner pid:52 preventSuspend   preventThrottleDownCPU preventThrottleDownUI)} 

는 많은 정보 라인처럼 제공이

Elapsed total CPU time (seconds): 10.030 (user 10.030, system 0.000), 100% CPU 
Elapsed application CPU time (seconds): 3.724, 37% CPU 

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0: 
0 libsystem_c.dylib    0x33be8b1e __vfprintf + 158 
1 libsystem_c.dylib    0x33b93106 vsnprintf_l + 170 
2 libsystem_c.dylib    0x33b9455c snprintf + 68 
3 libsystem_c.dylib    0x33b968a6 asl_string_append_char_no_encoding + 102 
4 libsystem_c.dylib    0x33b9694c asl_string_append_internal + 124 
5 libsystem_c.dylib    0x33b96536 asl_msg_to_string_raw + 118 
6 libsystem_c.dylib    0x33b95b06 _asl_send_message + 1018 
7 CoreFoundation     0x380d417a __CFLogCString + 602 
8 CoreFoundation     0x3807801e _CFLogvEx + 186 
9 Foundation      0x3a13ed8a NSLogv + 82 
10 Foundation      0x3a13ed2a NSLog + 22 
11 ContactPro      0x000a7d38 0xa4000 + 15672 
12 ContactPro      0x000a686e 0xa4000 + 10350 
13 ContactPro      0x000b9dd0 0xa4000 + 89552 
14 UIKit       0x37a6f590 -[UIViewController loadViewIfRequired] + 360 
15 UIKit       0x37ac4136 -[UIViewController contentScrollView] + 22 
16 UIKit       0x37ac407c -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 24 
17 UIKit       0x37ac3f60 -[UINavigationController _layoutViewController:] + 28 
18 UIKit       0x37ac3e84 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 268 
19 UIKit       0x37ac35c4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 60 
20 UIKit       0x37ac34ac -[UINavigationController _startDeferredTransitionIfNeeded:] + 320 
21 UIKit       0x37a944e4 -[UILayoutContainerView layoutSubviews] + 176 
22 UIKit       0x37a53806 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254 
23 QuartzCore      0x36145d5e -[CALayer layoutSublayers] + 210 
24 QuartzCore      0x361458fc CA::Layer::layout_if_needed(CA::Transaction*) + 456 
25 QuartzCore      0x361747a2 -[CALayer layoutIfNeeded] + 138 
26 UIKit       0x37afd0cc -[UIViewController window:setupWithInterfaceOrientation:] + 204 
27 UIKit       0x37afc2b8 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 3616 
28 UIKit       0x37afb48a -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 42 
29 UIKit       0x37afb414 -[UIWindow _setRotatableViewOrientation:duration:force:] + 64 
30 UIKit       0x37c3117c __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke_0 + 100 
31 UIKit       0x37ab967e -[UIWindow _updateToInterfaceOrientation:duration:force:] + 214 
32 UIKit       0x37ab93c0 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 688 
33 UIKit       0x37ab8d2e -[UIViewController _tryBecomeRootViewControllerInWindow:] + 154 
34 UIKit       0x37aafea6 -[UIWindow addRootViewControllerViewIfPossible] + 366 
35 UIKit       0x37aabae8 -[UIWindow _setHidden:forced:] + 360 
36 UIKit       0x37aed1cc -[UIWindow makeKeyAndVisible] + 56 
37 ContactPro      0x000a5c88 0xa4000 + 7304 
38 UIKit       0x37ab0ad4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 248 
39 UIKit       0x37ab065e -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1186 
40 UIKit       0x37aa8846 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 694 
41 UIKit       0x37a50c3c -[UIApplication handleEvent:withNewEvent:] + 1000 
42 UIKit       0x37a506d0 -[UIApplication sendEvent:] + 68 
43 UIKit       0x37a5011e _UIApplicationHandleEvent + 6150 
44 GraphicsServices    0x35ce35a0 _PurpleEventCallback + 588 
45 CoreFoundation     0x380bb680 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12 
46 CoreFoundation     0x380baee4 __CFRunLoopDoSources0 + 208 
47 CoreFoundation     0x380b9cb2 __CFRunLoopRun + 642 
48 CoreFoundation     0x3802ceb8 CFRunLoopRunSpecific + 352 
49 CoreFoundation     0x3802cd44 CFRunLoopRunInMode + 100 
50 UIKit       0x37aa7480 -[UIApplication _run] + 664 
51 UIKit       0x37aa42fc UIApplicationMain + 1116 
52 ContactPro      0x000a5864 0xa4000 + 6244 
53 libdyld.dylib     0x36982b1c start + 0 

사람이 그것을 해결하는 방법에 관한 몇 가지 팁을 제공 할 수 있습니다!

IOS6의 ADDRESS BOOK에 액세스하려면 다음 줄을 사용하고 있습니다. ABAddressBookRef ab = ABAddressBookCreateWithOptions (NULL, NULL);

__block BOOL accessGranted = NO; 
if (ABAddressBookRequestAccessWithCompletion != NULL) { // we're on iOS 6 
    dispatch_semaphore_t sema = dispatch_semaphore_create(0); 
    ABAddressBookRequestAccessWithCompletion(ab, ^(bool granted, CFErrorRef error) { 
     accessGranted = granted; 
     dispatch_semaphore_signal(sema); 
    }); 
    dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); 
    //  dispatch_release(sema); 
} 
else { // we're on iOS 5 or older 
    accessGranted = YES; 
} 

if (accessGranted) { 
    // Do whatever you want here 
} 

나는이 또한 내가 연락처에 대한 참조를 받고 있지 않다으로 주소록 액세스 코드,

ABAddressBookRef abcd = ABAddressBookCreateWithOptions(NULL, NULL); 
__block BOOL accessGranted = NO; 
    if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) { 
    ABAddressBookRequestAccessWithCompletion(abcd, ^(bool granted, CFErrorRef error) { 
     // First time access has been granted, add the contact 
     accessGranted = granted; 
    }); 
} 
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) { 
    // The user has previously given access, add the contact 
    accessGranted = YES; 
} 
else { 
    // The user has previously denied access 
    // Send an alert telling user to change privacy setting in settings app 
} 

if (accessGranted) { 
    CFIndex recordsCount = ABAddressBookGetPersonCount(abcd); 
    CFArrayRef all = ABAddressBookCopyArrayOfAllPeople(abcd); 
    ABRecordRef ref = CFArrayGetValueAtIndex(all,recordsCount); 
    NSLog(@"%@", ref); 
    ABRecordID record = ABRecordGetRecordID(ref); 
}                        

을 변경? .. 또한 응용 프로그램은 시뮬레이터 및 장치 모두에서 추락하기. 그러나 나는 AddressBook에 접근하고있다. #pls는 나를 제안합니다.이 문제를 해결하기 위해 수행 할 수있는 작업. 감사합니다

덕분에 & 감사

+0

작동 ? – sergio

+0

몇 가지 코드를 게시 할 수 있습니까? ABAddressBookRequestAccessWithCompletion을 사용하여 권한을 요청 하시겠습니까? – LombaX

+0

@LombaX 예, ABAddressBookRequestAccessWithCompletion을 사용하여 시뮬레이터에서 권한을 요청하고 작동 중입니다. #thanks for d 응답 – ibiren

답변

1

나는 문제가이 생각 : 당신이 "녹색 빛"이 나타날 때까지 스레드를 차단하는 세마포어를 사용하고 있습니다. 그러나이 코드는 스레드 0 (사용자 인터페이스를 관리하는 주 스레드)에서 실행 중입니다. 그런 이유로 연락처에 대한 액세스를 요청하는 경고를 포함하여 사용자 인터페이스의 모든 변경 사항을 차단합니다.

새 코드 에 대한 EDIT 첫 번째 일 : 장치를 사용해보십시오. 어떤 이유로 시뮬레이터는 항상 ABAddressBookGetAuthorizationStatus in simulator always returns kABAuthorizationStatusAuthorized이 아닌 경우에도 권한을 반환합니다.

전에 전에 완료 블록 (완료 블록이 사용자 결정을 기다리는)이 실행되기 때문에 사용자가 처음으로 응용 프로그램을 인증하면 "if (accessGranted)"가 실행되지 않습니다. 블록 바로 다음에 코드가 즉시 실행됩니다. 이 코드를 다른 함수 (예 : 승인 된 블록 한 번만 호출 된 후)에서 옮겨야합니다. 그러나 테스트 목적으로이 코드는 권한이 부여 된 AB에 액세스하려고 시도 할 때 다시 작동해야합니다.

액세스 권한 코드는 한 가지를 제외하고는 괜찮습니다. 250 개의 레코드 배열이있는 경우 레코드 250 (존재하지 않음, 마지막 레코드는 249)에 액세스하려고합니다. 이 줄을 내가 노력이

ABRecordRef ref = CFArrayGetValueAtIndex(all,recordsCount-1); 

ABRecordRef ref = CFArrayGetValueAtIndex(all,recordsCount); 

을 변경하고 당신이 어딘가에`beginBackgroundTaskWithExpirationHandler`를 사용하는

+0

제안에 따라 주소록 액세스 코드가 변경되었습니다.하지만 내가 만든 새 연락처에 대한 참조를 얻지 못하고 있습니다. 업데이트 된 코드를 확인하십시오. # 감사합니다 – ibiren

+0

대답을 편집했습니다. 확인해주세요. – LombaX

+0

답변 해 주셔서 감사합니다. 그것은 작동합니다! 이전에 나는 AddressBook에 하나의 질문을 올렸습니다. pls 수, 그것을 확인하십시오. [그래서] (http://stackoverflow.com/questions/12669305/how-to-check-whether-organization-name-is-added-before-saving-contact-in-address) #i 당신이 대답 할 수 있으면 좋겠 if u는 비슷한 일을했습니다. # 고마워요 – ibiren

관련 문제