我正在开发一个新地址簿的应用程序。是否存在用于创建按钮以将您的联系人(从现有地址簿)导入我的应用程序的代码?如果可能,请为这些新联系人添加* 67?
答案 0 :(得分:2)
您需要了解如何从地址簿导入联系人。
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号码,然后保存该新字符串。