Check if ABMultiValueRef is has no values

不问归期 提交于 2019-12-13 19:38:40

问题


I want to check if a contact in my user's addressbook a phone number has. If he does, I want to display that name in an UITableView

I've tried to check for phoneNumbers != nil, but that doesn't work. This is my entire code:

ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if(phoneNumbers != nil){
  [_numbers addObject:[NSString stringWithFormat:@"%@", phoneNumbers]];
}

回答1:


Use ABMultiValueGetCount to check if phoneNumbers has any values in it.

example based on question:

ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if(ABMultiValueGetCount(phoneNumbers)){
    [_numbers addObject:[NSString stringWithFormat:@"%@", phoneNumbers]];
}


来源:https://stackoverflow.com/questions/24534436/check-if-abmultivalueref-is-has-no-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!