0
ABAddressBookRef ab = ABAddressBookCreate();
CFErrorRef error;
ABRecordRef group = ABGroupCreate();
ABRecordSetValue(group, kABGroupNameProperty,@"new group", &error);
ABAddressBookAddRecord(ab, group, &error);
ABAddressBookSave(ab, &error);

CFRelease(group);

I try this code for creating contacts group. How ever I m not success. Need help on this.

UPDATE:

CFErrorRef error;
ABAddressBookRef ab = ABAddressBookCreateWithOptions(NULL,&error);
ABRecordRef group = ABGroupCreate();
ABRecordSetValue(group, kABGroupNameProperty,@"new group", &error);
ABAddressBookAddRecord(ab, group, &error);
ABAddressBookSave(ab, &error);
NSLog(@"%@",error);
CFRelease(group);

now only print (null).....

ekad
  • 14,436
  • 26
  • 44
  • 46
Antiokhos
  • 2,944
  • 5
  • 23
  • 32
  • 1
    You have an error parameter but you aren't checking it. I'd suggest that's the first thing to do. Also - check the documentation - ABAddressBookCreate() is deprecated. – Abizern Nov 28 '13 at 12:51
  • Get idea from here: http://stackoverflow.com/questions/5712740/create-a-group-in-address-book-for-iphone – Bhumeshwer katre Nov 28 '13 at 12:57
  • @Bhumeshwerkatre I try that code in link. Contacts adding successfully how ever not create group. – Antiokhos Nov 28 '13 at 13:48
  • Does the app have permission to access the Address book? Have a look at this answer to set it up. http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts Also, you should be checking the result of calls that have an error reference and check the error on failure; don't just log the error at the end. – Abizern Nov 28 '13 at 16:06
  • yes the app has permission to access contacts.... and still no result.. – Antiokhos Nov 29 '13 at 19:12

0 Answers0