0

I am learning iPhone programming, I am trying to add contacts to specific group. I have an array of all contacts and I want to add selected contact to group. Here is my code :

        for (int i = 0; i < [array count]; i++)
        {
           ABRecordRef person = [array objectAtIndex:i];
           group  = ABAddressBookGetGroupWithRecordID(addressBook, groupId);
           BOOL didAdd = ABGroupAddMember(group, person, &err);

           if (didAdd) {
              NSLog(@"added");
           }
        }

It returns NO. I dont know why.

memmons
  • 40,222
  • 21
  • 149
  • 183
user2169470
  • 33
  • 1
  • 3

1 Answers1

0

Log the error.

 if (didAdd == NO) {
      NSLog(@"Error Adding Contact:%@\n%@",err.localizedDescription,err.localizedFailureReason);
 }
Jack Freeman
  • 1,414
  • 11
  • 18
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Jon Egerton Mar 14 '13 at 21:01
  • "It returns NO. I dont know why." was the question. I'm telling him how to find out why and therefore answering the question. – Jack Freeman Mar 14 '13 at 21:09
  • No - you're telling him how to find out. You're not telling him why. Its great that you're helping to find out, but it should be a comment as it doesn't actually explain what is causing the issue. – Jon Egerton Mar 14 '13 at 22:32