Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-10-2010, 06:15 PM   #1 (permalink)
gtyt38
 
Join Date: Apr 2010
Location: Baltimore, MD, USA
Posts: 61
gtyt38 is on a distinguished road
Default Add contact to ABAddressBook

Hi all, I am trying to add a contact's info to the device's address book using this code:

Code:
- (IBAction)addContact:(id)sender {
	ABAddressBookRef addressBook = ABAddressBookCreate();
	ABRecordRef person = ABPersonCreate();
	
	ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
	ABMultiValueAddValueAndLabel(phoneNumberMultiValue,formattedHomeNumber,kABPersonPhoneMainLabel, NULL);
	
	ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
	ABMultiValueAddValueAndLabel(emailMultiValue, emailAddress, kABHomeLabel,NULL);
	
	ABRecordSetValue(person, kABPersonFirstNameProperty, firstName , nil);
	ABRecordSetValue(person, kABPersonLastNameProperty, lastName, nil);
	ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue,nil);
	
	ABAddressBookAddRecord(addressBook, person, nil);
	ABAddressBookSave(addressBook, nil);
	
	CFRelease(person);
	
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contact Saved Successfully" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
	[alert show];
	[alert release];
}
The user selects a row from a UITableView and can view a contact's information, then click a button to store that info to the address book. The problem is with storing phone numbers. I can only store one phone number at a time (I would like to use two different fields for the home and mobile number), and the app randomly crashes when trying to enter certain numbers. Thanks in advance!

Greg

P.S. This is an in-house app, so don't worry about any private APIs!
__________________
No animals were injured in the creation of this post…however, a few electrons were mildly inconvenienced…
gtyt38 is offline   Reply With Quote
Old 09-11-2010, 02:41 PM   #2 (permalink)
gtyt38
 
Join Date: Apr 2010
Location: Baltimore, MD, USA
Posts: 61
gtyt38 is on a distinguished road
Default

*bump*
__________________
No animals were injured in the creation of this post…however, a few electrons were mildly inconvenienced…
gtyt38 is offline   Reply With Quote
Reply

Bookmarks

Tags
abaddressbook, contact add, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 338
13 members and 325 guests
bignoggins, carlandrews, cgokey, flamingliquid, givensur, hzwegjxg, ilmman, jenniead38, linkmx, mraalex, PixelInteractive, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:55 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0