我正在使用以下代码从通讯录中检索用户的电话号码
ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);
//EXC_BAD_ACCESS error if a user does not have phone number stored in the address book
CFStringRef pNumber = ABMultiValueCopyValueAtIndex(phones,0);
NSString *phoneNumber = [NSString stringWithFormat:@"%@", (NSString *)pNumber]
当用户在通讯录中没有电话号码时会出现此问题,从而导致错误“EXC_BAD_ACCESS”错误。我的问题是如何检查该用户的电话号码是否存在?并且仅在该值存在时才继续访问该值?