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 04-27-2010, 04:59 AM   #1 (permalink)
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
Johanovski is on a distinguished road
Default Accessing contacts info WITHOUT the address book?

Hi there!

I'm working in an application where I want to access the iPhone's address book to take contacts' names, but I want to do this programmatically and automatically, so I don't want to use the Address Book UI to select a contact. It's possible to get the address book content without user interaction so I can get their names?

Thanks in advance!
Johanovski is offline   Reply With Quote
Old 04-27-2010, 08:47 AM   #2 (permalink)
Registered Member
 
Jagged's Avatar
 
Join Date: May 2009
Age: 30
Posts: 49
Jagged is on a distinguished road
Default

maybe this can help you

Code:
	addressBook = ABAddressBookCreate();
	personRecord = ABAddressBookCopyArrayOfAllPeople(addressBook);
	
	personArray = [[NSMutableArray alloc] init];
	
	for (int i = 0; i < CFArrayGetCount(personRecord); i++)
	{
		ABRecordRef personRef = (ABRecordID*)CFArrayGetValueAtIndex(personRecord, i);
		ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, ABRecordGetRecordID(personRef));
		
		@try 
		{
			if (ABRecordCopyValue(person, kABPersonBirthdayProperty))
				[personArray addObject: (id)personRef];
		}
		@catch (NSException * e) 
		{
		}
		@finally 
		{
		}
	}
with this code you can create a list ob personreference IDs

Use this code to get person informations:

Code:
		NSString *FirstName = [NSString stringWithString:(NSString *)ABRecordCopyValue(aPersonRef, kABPersonFirstNameProperty)];

search for "kABPersonFirstNameProperty" in the sdk documentation to find other personal information properties
__________________
iPhoneDist.com - distribution service for iPhone applications

New App: tubeProphet

Apps: Time Prophet, Textshare
Jagged is offline   Reply With Quote
Reply

Bookmarks

Tags
address, address book, contacts

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: 321
21 members and 300 guests
Abidullah, baja_yu, cgokey, Domele, Duncan C, Fstuff, gbenna, givensur, guusleijsten, HowEver, iphonedevshani, jbro, JoeRCruso, mdpauley, n00b, newDev, seokwon lee, SLIC, stanny, Steven.C, WheyLabs
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,112
Posts: 402,876
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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