2

I am working on an app for a new address book. Is there code existing to make a button to import your contact (from existing address book) into my app? And add *67 to these new contacts if possible?

4

1 回答 1

2

您需要阅读如何从通讯录中导入联系人。

ABAddressBook 类参考

这是一个例子

CFStringRef phone,phoneLabel;
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSMutableDictionary *myPhoneDict = [NSMutableDictionary dictionaryWithCapacity:ABMultiValueGetCount(phoneMulti)];
for (CFIndex i = 0; i < ABMultiValueGetCount(phoneMulti); i++) { 
    phoneLabel = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(phoneMulti, i));
    phone = ABMultiValueCopyValueAtIndex(phoneMulti, i); 
    [myPhoneDict setObject:(NSString*)phone forKey:(NSString*)phoneLabel];
    CFRelease(phone);
    CFRelease(phoneLabel);
} 
if ( [myPhoneDict objectForKey:@"mobile"] != nil) {
    NSLog(@"Cell Phone: %@",[myPhoneDict objectForKey:@"mobile"]);
} 

else if ( [myPhoneDict objectForKey:@"home"] != nil) {
    NSLog(@"Home Phone: %@",[myPhoneDict objectForKey:@"home"]);
} 

else if ( [myPhoneDict objectForKey:@"work"] != nil) {
    NSLog@"Work Phone: %@",[myPhoneDict objectForKey:@"work"]);
}

然后,您可以获取您要查找的任何数字并将您的 *67 数字添加到其中,然后保存该新字符串。

于 2012-05-28T22:57:23.537 回答