转载: http://blog.sina.com.cn/s/blog_80fd103101013to0.html
ABAddressBookRef addressBook = ABAddressBookCreate();
//初始化一个recordABRecordRef person = ABPersonCreate();
//这是一个空的记录,或者说是没有任何信息的联系人
//下面给这个人 添加一个名字
NSString *firstName = @"Tr";
ABRecordSetValue(person, kABPersonFirstNameProperty, (CFStringRef)firstName, NULL);
NSString *lastName = @"Lee";
ABRecordSetValue(person, kABPersonLastNameProperty, (CFStringRef)lastName, NULL);
//给他再加一个生日
NSDate *bdate = [NSDate date];
ABRecordSetValue(person, kABPersonBirthdayProperty, (CFDateRef)bdate, NULL);
//备忘
NSString *temNote = @"note test";
ABRecordSetValue(person, kABPersonNoteProperty, (CFStringRef)temNote, NULL);
// //这些都是单一值属性的设置,接下来看看多值属性的设置
// NSArray *phones = [NSArray arrayWithObjects:@"123", @"456", nil];
// NSArray *labels = [NSArray arrayWithObjects:@"iphone", @"home", nil];
// //初始化一个多值对象,类似字典
//
// ABMutableMultiValueRef mulRef = ABMultiValueCreateMutable(kABMultiStringPropertyType);
//
// //循环设置值
//
// for(int i = 0; i < phones.count; i++){
//
// ABMultiValueIdentifier multivalueIdentifier;
//
// ABMultiValueAddValueAndLabel(mulRef, (CFStringRef)[phones objectAtIndex:i], (CFStringRef)[labels objectAtIndex:i], &multivalueIdentifier);
//
// }
//
// ABRecordSetValue(person, kABPersonPhoneProperty, mulRef, NULL);
//
// if(mulRef)
//
// CFRelease(mulRef);
//将新的记录,添加到通讯录中
ABAddressBookAddRecord(addressBook, person, NULL);
//通讯录执行保存
ABAddressBookSave(addressBook, NULL);
//不说了,你懂的~
if(addressBook)
CFRelease(addressBook);