如何从 iPhone 通讯录中检索手机号码。
我使用以下代码在我的应用程序中设置检索电话号码。
CFStringRef addressBookMobile;
ABRecordRef person;
NSString *mobile;
person = CFArrayGetValueAtIndex(people, i);
addressBookMobile = ABRecordCopyValue(person, kABPersonPhoneProperty);
mobile = [NSString stringWithFormat:@"%@", addressBookMobile];
联系人的标签是“移动”。但是,当我使用 NSLog(@"%@", mobile);
时。它显示
。我的代码有什么问题吗?
我应该使用 const CFStringRef kABPersonPhoneMobileLabel 以及如何使用?如果我将其替换为上面的代码,则会出现错误。谁能帮助我吗?谢谢。
I use the following code to set the retrieve the phone number in my app.
CFStringRef addressBookMobile;
ABRecordRef person;
NSString *mobile;
person = CFArrayGetValueAtIndex(people, i);
addressBookMobile = ABRecordCopyValue(person, kABPersonPhoneProperty);
mobile = [NSString stringWithFormat:@"%@", addressBookMobile];
The tag of the contacts is 'mobile'. However, when I use the NSLog(@"%@", mobile);
. It displays the <NSCFType: 0x802ffc0>
. does any problem for my code?
Should I use the const CFStringRef kABPersonPhoneMobileLabel
and how to use? As if I replace it as the above code, it has the error. Can anyone help me? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查 ABPerson 参考,您不需要使用 @"$!!$" 而是 kABPersonPhoneMobileLabel。例子是:
check the ABPerson Refrence and You need't use @"$!!$" but kABPersonPhoneMobileLabel. the example is:
地址簿中人员的电话号码采用多值属性的形式。
在你的情况下,你应该有类似下面的东西(还没有尝试过,直接在此处输入,所以我不知道它是否可以编译和/或工作):
The phone numbers of a person in the Address Book are in the form of a multi-value property.
In your case, you should have something like the following (haven't tried it, typing directly here, so I don't know if it compiles and/or works):
这对于 ARC 64 位 iOS8 来说是可靠的:
This is solid for ARC 64bit iOS8: