bugly定位IOS SEGV_ACCERR 异常, 各位大神帮忙看下代码哪里有问题
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
didSelectPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier {
[YZTBaseHudTips hideHud:self.view];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
ABMutableMultiValueRef name = ABRecordCopyCompositeName(person);
if (property == kABPersonPhoneProperty) {
ABMutableMultiValueRef phone = ABRecordCopyValue(person, kABPersonPhoneProperty);
//根据电机的哪一行对应的identifier取出所在的索引
int index = ABMultiValueGetIdentifierAtIndex(phone, identifier);
CFStringRef phoneRef = ABMultiValueCopyValueAtIndex(phone, index);
[self updateMobileCell:(__bridge NSString *)name phone:(__bridge NSString *)(phoneRef) peoplePicker:peoplePicker];
CFRelease(phoneRef);
CFRelease(phone);
}
CFRelease(name);
}
crash 上报这一行出问题: int index = ABMultiValueGetIdentifierAtIndex(phone, identifier);
下边是错误堆栈
libobjc.A.dylib objc_retain + 16
1 cardloan -[ApplyContactsInfoViewController updateMobileCell:phone:peoplePicker:] (ApplyContactsInfoViewController.m:448)
2 cardloan -[ApplyContactsInfoViewController peoplePickerNavigationController:didSelectPerson:property:identifier:] (ApplyContactsInfoViewController.m:540)
3 ContactsUI -[CNContactPickerViewController pickerDidSelectContact:property:] + 296
4 ContactsUI -[CNContactPickerHostViewController pickerDidSelectContact:property:] + 100
5 ContactsUI ___71-[CNContactPickerExtensionHostContext pickerDidSelectContact:property:]_block_invoke + 60
6 libdispatch.dylib __dispatch_call_block_and_release + 24
7 libdispatch.dylib __dispatch_client_callout + 16
8 libdispatch.dylib _dispatch_main_queue_callback_4CF + 1844
9 CoreFoundation ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
10 CoreFoundation ___CFRunLoopRun + 1628
11 CoreFoundation CFRunLoopRunSpecific + 384
12 GraphicsServices GSEventRunModal + 180
13 UIKit UIApplicationMain + 204
14 cardloan main (main.m:14)
15 libdyld.dylib _start + 4
使用
ABMultiValueGetIdentifierAtIndex
之前要先检查 index 是否合格,使用ABMultiValueGetCount
获取数目,然后用 identifier 比较用户点击了那一行。例如:参考:http://stackoverflow.com/a/12...
SEGV_ACCERR一般是内存问题,在64位上比较常见,比如多线程操作某变量,堆栈非法访问等。