I have an array of contacts, when I am trying to add a contact into a group, its crash my application. Here is my code :
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");
}
}
My application crashes on ABRecordRef newPerson = [contactArray objectAtIndex:i];
How can I get the record of a person from the array to add it to a group ?