检查ABMultiValueRef是没有值 [英] Check if ABMultiValueRef is has no values

查看:179
本文介绍了检查ABMultiValueRef是没有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查,如果在我的用户的地址簿中的联系人的电话号码了。如果他这样做,我想在一个的UITableView以显示名称

我试过检查 PHONENUMBERS!=零,但不起作用。这是我的整个code:

  ABMultiValueRef PHONENUMBERS = ABRecordCopyValue(人,kABPersonPhoneProperty);如果(PHONENUMBERS!=无){
  [_numbers ADDOBJECT:[的NSString stringWithFormat:@%@,PHONENUMBERS]];
}


解决方案

使用 ABMultiValueGetCount 来检查是否PHONENUMBERS中有任何值。

例如基于问题:

  ABMultiValueRef PHONENUMBERS = ABRecordCopyValue(人,kABPersonPhoneProperty);如果(ABMultiValueGetCount(PHONENUMBERS)){
    [_numbers ADDOBJECT:[的NSString stringWithFormat:@%@,PHONENUMBERS]];
}

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]];
}

解决方案

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]];
}

这篇关于检查ABMultiValueRef是没有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆