我正在为新地址簿开发应用程序。是否存在用于创建按钮以将您的联系人(从现有地址簿)导入我的应用程序的代码?并在可能的情况下在这些新联系人中添加* 67?
最佳答案
您需要阅读有关如何从通讯录导入联系人的信息。
ABAddressBook Class Reference
这是一个例子
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号,然后保存该新字符串。