Note that there are some explanatory texts on larger screens.

plurals
  1. POAddress book implementation not working
    primarykey
    data
    text
    <p>I am using XCode 4.2 to develop a function to add a contact to the address book , here is my code</p> <pre><code> ABAddressBookRef *iPhoneAddressBook = ABAddressBookCreate(); ABRecordRef contact = ABPersonCreate(); //add infos ABRecordSetValue(contact, kABPersonFirstNameProperty,(__bridge_retained CFStringRef)firstName, nil); ABRecordSetValue(contact, kABPersonLastNameProperty,(__bridge_retained CFStringRef)lastName, nil); ABRecordSetValue(contact, kABPersonOrganizationProperty, (__bridge_retained CFStringRef)organization, nil); ABRecordSetValue(contact, kABPersonJobTitleProperty, (__bridge_retained CFStringRef)title, nil); ABMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiRealPropertyType); ABMultiValueAddValueAndLabel(multiPhone, (__bridge_retained CFStringRef)workTel, kABPersonPhoneMainLabel, NULL); ABMultiValueAddValueAndLabel(multiPhone, (__bridge_retained CFStringRef)workFax, kABPersonPhoneWorkFAXLabel, NULL); ABRecordSetValue(contact, kABPersonPhoneProperty, multiPhone, nil); CFRelease(multiPhone); ABMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multiEmail, (__bridge_retained CFStringRef)email, kABWorkLabel, NULL); ABRecordSetValue(contact, kABPersonEmailProperty, multiEmail, nil); CFRelease(multiEmail); // address ABMultiValueRef multiAddress =ABMultiValueCreateMutable(kABMultiDictionaryPropertyType); NSMutableDictionary *addressDict = [[NSMutableDictionary alloc]init]; [addressDict setObject:address forKey:(NSString *) kABPersonAddressStreetKey]; [addressDict setObject:city forKey:(NSString *) kABPersonAddressCityKey]; [addressDict setObject:province forKey:(NSString *) kABPersonAddressStateKey]; [addressDict setObject:postalCode forKey:(NSString *) kABPersonAddressZIPKey]; [addressDict setObject:address forKey:(NSString *) kABPersonAddressCountryKey]; ABMultiValueAddValueAndLabel(multiAddress, (__bridge_retained CFStringRef)addressDict, kABWorkLabel, NULL); ABRecordSetValue(contact, kABPersonAddressProperty, multiAddress, NULL); CFRelease(multiAddress); ABMultiValueRef multiURL =ABMultiValueCreateMutable(kABMultiRealPropertyType); ABMultiValueAddValueAndLabel(multiURL, (__bridge_retained CFStringRef)link, kABPersonURLProperty, NULL); CFRelease(multiURL); ABAddressBookAddRecord(iPhoneAddressBook, contact, nil); BOOL didAdd = ABAddressBookSave(iPhoneAddressBook, nil); CFRelease(contact); CFRelease(iPhoneAddressBook); //notifying the user that it was stored in his address book if (didAdd) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirmation" message:@"Contact Info successfully added to the Address Book" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } </code></pre> <p>the program compiles and but it stops at this line :</p> <pre><code>ABMultiValueAddValueAndLabel(multiPhone, (__bridge_retained CFStringRef)workTel, kABPersonPhoneMainLabel, NULL); </code></pre> <p>I get this error (in green)</p> <pre><code>Thread 1 </code></pre> <p>any clue ? what is wrong in the code ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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