2013-09-21 79 views
1

嗨,當我在崩潰日誌中的錯誤,我無法理解:SIGSEGV崩潰使用AddressBookUI框架

Incident Identifier: A0DFD1F1-8CB5-4D97-B19C-F73438F50136 
CrashReporter Key: [TODO] 
Hardware Model:  iPhone4,1 
Process:   Rubrica4146 [1163] 
Path:   /var/mobile/Applications/A8BF5FB7-C32B-4A8C-A7AA-E6F6D94DF2EB/Rubrica4146.app/Rubrica4146 
Identifier:  com.7shapes.rubrica4146 
Version:   27 
Code Type:  ARM 
Parent Process: launchd [1] 

Date/Time:  2013-09-20 15:38:31 +0000 
OS Version:  iPhone OS 7.0 (11A465) 
Report Version: 104 

Exception Type: SIGSEGV 
Exception Codes: SEGV_ACCERR at 0xc0000004 
Crashed Thread: 0 

Thread 0 Crashed: 
0 CoreFoundation      0x303b004c CFRetain + 8 
1 Rubrica4146       0x000ce3d3 -[AppDelegate personViewController:shouldPerformDefaultActionForPerson:property:identifier:] (AppDelegate.m:752) 
2 AddressBookUI      0x2fb61385 -[ABPersonViewController_Modern contactViewController:shouldPerformDefaultActionForContact:property:labeledValue:] + 177 
3 AddressBookUI      0x2faf0133 -[ABContactViewController tableView:didSelectRowAtIndexPath:] + 659 
4 UIKit        0x32d1032b -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1079 
5 UIKit        0x32dc3253 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 215 
6 UIKit        0x32c73971 _applyBlockToCFArrayCopiedToStack + 317 
7 UIKit        0x32beb473 _afterCACommitHandler + 431 
8 CoreFoundation      0x3044d1d5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21 
9 CoreFoundation      0x3044ab79 __CFRunLoopDoObservers + 285 
10 CoreFoundation      0x3044aebb __CFRunLoopRun + 731 
11 CoreFoundation      0x303b5ce7 CFRunLoopRunSpecific + 523 
12 CoreFoundation      0x303b5acb CFRunLoopRunInMode + 107 
13 GraphicsServices     0x350d6283 GSEventRunModal + 139 
14 UIKit        0x32c57a41 UIApplicationMain + 1137 
15 Rubrica4146       0x000ca6af main (main.m:16) 

,這是似乎產生它的方法:

-(BOOL) personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{ 
    if (property == kABPersonPhoneProperty){ 
     NSString *number = nil; 
     ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, property); 
     if (ABMultiValueGetCount(phoneNumbers) > 0) { 
      number = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, identifier); 
      [self setInfoForPersonToCall:person]; 
      self.numberToSave = number; 
      self.numberToCall = number; 
      if (self.shouldSendSMS) { 
       [self prepareToSMSNumber]; 
      } else { 
       [self prepareToCallNumber]; 
      } 
     } 
     if (phoneNumbers != nil) 
      CFRelease(phoneNumbers); 
    } 
    return NO; 
} 

有誰知道如何解決它? 我相信ARC內存管理和__bridge_transfer存在一個問題。 感謝

+0

我還注意到,「人」保留計數總是增加當我選擇不同的用戶(一個這樣做的通訊錄目的)。這是正常的嗎? –

回答

0

嘗試迭代直通聯繫人的電話號碼(在kABPersonPhoneProperty多值),使用CFBridgingRelease

// Access the person's phone numbers (an ABMultiValueRef) 
ABMultiValueRef phoneProperty = ABRecordCopyValue(person, kABPersonPhoneProperty); 

if (phoneProperty) 
{ 
    // Iterate through the phone multivalue 
    for (CFIndex index = 0; index < ABMultiValueGetCount(phoneProperty); index++) 
    { 
     // Get the phone identifier for this phone property 
     ABMultiValueIdentifier phoneIdentifier = ABMultiValueGetIdentifierAtIndex(phoneProperty, index); 

     // Get the phone number 
     NSString *phoneNumber = CFBridgingRelease(ABMultiValueCopyValueAtIndex(phoneProperty, index)); 
    } 
}