1
我試圖將選定的聯繫人添加到特定的組,但聯繫人不能添加到組中。 我想要創建新組並將聯繫人添加到該組中。但該組無法添加contacts.here創建組後是我的代碼創建新組並添加聯繫人到組:無法使用ABGroupAddMember將聯繫人添加到iPhone中的特定組中
addressBook = ABAddressBookCreateWithOptions(nil, &err);
group = ABGroupCreate();
ABRecordSetValue(group, kABGroupNameProperty, txtGroupNameText.text, &err);
ABAddressBookAddRecord(addressBook, group, &err);
ABAddressBookSave(addressBook, &err);
groupId = ABRecordGetRecordID(group);
和添加聯繫人:
ABRecordRef person = [contactArray objectAtIndex:i];
ABRecordRef HiByeGroup = ABAddressBookGetGroupWithRecordID(addressBook, self.groupId);
BOOL didAdd = ABGroupAddMember(HiByeGroup,person,&err);
if (didAdd) {
// Update to handle the error appropriately.
NSLog(@"Unresolved error while adding person to HiBye group");
}
BOOL didSave = ABAddressBookSave(addressBook, &err);
if (didSave) {
// Update to handle the error appropriately.
NSLog(@"Unresolved error while saving address book");
}
電子觸點節約但不得到add.Please幫助我,謝謝。
謝謝,它的作品不錯,但我的所有聯繫人的一個可變數組並從該數組我試圖添加到組接觸,我怎樣才能做到這一點?因爲我的應用程序崩潰了ABRecordRef person = [contactArray objectAtIndex:i];在這條線上。 – newDev