Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I set an Instant Message property on an Address Book contact?
    text
    copied!<p>I have the following code that I'm trying to use to set the AIM and Skype properties of a new contact I'm adding to Address Book:</p> <pre><code>ABRecordRef record = ABPersonCreate(); CFErrorRef an_error = NULL; ABMutableMultiValueRef multi_aim = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multi_aim, @"ExampleNick", kABPersonInstantMessageServiceAIM, NULL); ABRecordSetValue(record, kABPersonInstantMessageProperty, multi_aim, &amp;an_error); ABMutableMultiValueRef multi_skype = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multi_skype, @"example.nick", kABPersonInstantMessageServiceSkype, NULL); ABRecordSetValue(record, kABPersonInstantMessageProperty, multi_skype, &amp;an_error); if (an_error != NULL) { NSLog(@"Error while creating person"); } CFErrorRef error = NULL; ABAddressBookRef address_book = ABAddressBookCreateWithOptions(NULL, &amp;error); ABAddressBookRequestAccessWithCompletion(address_book, ^(bool granted, CFErrorRef error) { if (!granted) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unable to access address book" delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; [alert show]; } else { BOOL is_added = ABAddressBookAddRecord(address_book, record, &amp;error); if (is_added) { NSLog(@"Address book entry added"); } else { NSLog(@"ERROR adding address book entry: %@", error); } error = NULL; BOOL is_saved = ABAddressBookSave(address_book, &amp;error); if (is_saved) { NSLog(@"Saved address book"); } else { NSLog(@"ERROR saving address book: %@", error); } } CFRelease(record); CFRelease(multi_aim); CFRelease(multi_skype); CFRelease(address_book); }); </code></pre> <p>(I'm also adding first and last names but left that out of the example for brevity sake)</p> <p>When the record gets added everything but the AIM and Skype fields get populated. What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload