我有一组联系人,当我尝试将联系人添加到组中时,它会使我的应用程序崩溃。这是我的代码:
for (int i = 0; i < [contactArray count]; i++)
{
ABRecordRef newPerson = [contactArray objectAtIndex:i];
ABRecordSetValue(newPerson, kABPersonFirstNameProperty,name, &error);
ABRecordSetValue(newPerson, kABPersonPhoneProperty, phone,nil);
ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error);
ABAddressBookSave(iPhoneAddressBook, &error);
BOOL add = ABGroupAddMember(newGroup, newPerson, &error);
if (add) {
NSLog(@"added");
}
}
我的应用程序崩溃ABRecordRef newPerson = [contactArray objectAtIndex:i];
如何从数组中获取一个人的记录以将其添加到组中?