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.
check the ABPerson Refrence and You need't use @"$!!$" but kABPersonPhoneMobileLabel. the example is:
ABMultiValueRef phones = (ABMultiValueRef)ABRecordCopyValue(person, kABPersonPhoneProperty);
NSString* mobile=@"";
NSString* mobileLabel;
for (int i=0; i < ABMultiValueGetCount(phones); i++) {
//NSString *phone = (NSString *)ABMultiValueCopyValueAtIndex(phones, i);
//NSLog(@"%@", phone);
mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);
if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel]) {
NSLog(@"mobile:");
} else if ([mobileLabel isEqualToString:(NSString*)kABPersonPhoneIPhoneLabel]) {
NSLog(@"iphone:");
} else if ([mobileLabel isEqualToString:(NSString*)kABPersonPhonePagerLabel]) {
NSLog(@"pager:");
}
[mobile release];
mobile = (NSString*)ABMultiValueCopyValueAtIndex(phones, i);
NSLog(@"%@", mobile);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With