IOS Create new contacts group

//
//add new group
-(void) AddNewGroup:(NSString*)NewGroup {
    //check if the group name available
    if([self checkIfGroupAvailable: NewGroup]){return;}
    //create new address book to interact with contacts
    ABAddressBookRef addressbook = ABAddressBookCreate();
    //new record as group
    ABRecordRef      myGroup     = ABGroupCreate();
    //set name for myGroup kABGroupNameProperty
    ABRecordSetValue(myGroup, kABGroupNameProperty, ((__bridge CFStringRef)NewGroup), nil);
    //store group to address book object preparing to save
    ABAddressBookAddRecord(addressbook, myGroup, nil);
    //save group to contacts
    ABAddressBookSave(addressbook, nil);
    //dont forget to release C objects.
    CFRelease(myGroup);
    CFRelease(addressbook);
}

Comments

Popular posts from this blog

Java : Variables Declaring

Install DNF in RHEL/CentOS 7

SQL Self JOIN