Below is the code for adding a contact to iPhone’s Address Book using iPhone SDK.
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABPersonCreate();
ABRecordSetValue(person, kABPersonFirstNameProperty, @"Sudha" , nil);
ABRecordSetValue(person, kABPersonLastNameProperty, @"Reddy", nil);
ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABPersonPhoneProperty);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @"1234567890", kABHomeLabel, nil);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @"9876543210", kABPersonPhoneMobileLabel, nil);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @"04022222222", kABWorkLabel, nil);
ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue, nil);
ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABPersonEmailProperty);
ABMultiValueAddValueAndLabel(emailMultiValue, @"whatever@gmail.com", kABWorkLabel, nil);
ABRecordSetValue(person, kABPersonEmailProperty, emailMultiValue, nil);
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObjects:@"1234 Whatever Street", @"Hyderabad", @"AP", @"INDIA", @"500008", nil] forKeys: [NSArray arrayWithObjects: (NSString *)kABPersonAddressStreetKey, (NSString *)kABPersonAddressCityKey, (NSString *)kABPersonAddressStateKey, (NSString *)kABPersonAddressCountryKey, (NSString *)kABPersonAddressZIPKey, nil]];
ABMultiValueRef addressMultiValue = ABMultiValueCreateMutable(kABDictionaryPropertyType);
ABMultiValueAddValueAndLabel(addressMultiValue, (CFDictionaryRef *)dictionary, kABWorkLabel, nil);
ABRecordSetValue(person, kABPersonAddressProperty, addressMultiValue, nil); ABRecordCopyValue(person, kABPersonAddressProperty);
ABAddressBookAddRecord(addressBook, person, nil);
ABAddressBookSave(addressBook, nil);
CFRelease(person);
CFRelease(addressMultiValue);
CFRelease(phoneNumberMultiValue);
CFRelease(emailMultiValue);
[dictionary release];