开发者

How to check if phone number exists for a particular user in address book

开发者 https://www.devze.com 2023-04-05 11:56 出处:网络
I am using the following code to retrieve the user\'s phone numbers from the address book ABMul开发者_运维百科tiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);

I am using the following code to retrieve the user's phone numbers from the address book

ABMul开发者_运维百科tiValueRef 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]

The issue arises when the user does not have a phone number in the address book, resulting in the error 'EXC_BAD_ACCESS' error. My question is how can I check if for that user, a phone number exists? And only proceed to access the value only if it exists?


How to check the number of phone numbers.

ABMultiValueGetCount(ABRecordCopyValue(aPerson, kABPersonPhoneProperty));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号