现在的位置: 首页 > 综合 > 正文

通讯录添加信息

2018年02月02日 ⁄ 综合 ⁄ 共 716字 ⁄ 字号 评论关闭
  ABAddressBookRef addressBook = ABAddressBookCreate();
    
    //初始化一个record
    ABRecordRef 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);
    
    //将新的记录,添加到通讯录中
    
    ABAddressBookAddRecord(addressBook, person, NULL);
    
    //通讯录执行保存
    
    ABAddressBookSave(addressBook, NULL);
    
    //不说了,你懂的~
    
    if(addressBook)
        
        CFRelease(addressBook);

抱歉!评论已关闭.