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

View Single Post
Old 03-06-2010, 04:36 AM   #1 (permalink)
StefanL
Registered Member
 
Join Date: Jul 2009
Location: Wien/Austria
Posts: 242
StefanL is on a distinguished road
Default Addressbook - ID Issue in Simulator

Hi Folks,

when I try to get the recordID from Addressbook in Simulator, the ID is every time I start the Simulator different:

Code:
ABAddressBookRef addressBook = ABAddressBookCreate();
	
	CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
	CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
	
	masterList = [[NSMutableArray alloc] init];
	userID = [[NSMutableArray alloc] init];
	
	for (int i = 0; i < nPeople; i++) {
		ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
		CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
		CFStringRef lastName = ABRecordCopyValue(ref, kABPersonLastNameProperty);
		NSNumber *recordId = [NSNumber numberWithInteger: ABRecordGetRecordID(ref)];
		addId = [NSString stringWithFormat:@"%d", (NSNumber *)recordId];
		NSString *contactFirstLast = [NSString stringWithFormat: @"%@, %@",(NSString *)lastName, (NSString *)firstName];
		NSString *userId = [NSString stringWithFormat:@"%@, %@, %d", (NSString *)lastName, (NSString *)firstName, (NSNumber *)recordId];
		CFRelease(firstName);
		CFRelease(lastName);
		

		
		
		[masterList addObject:contactFirstLast];
		[userID addObject:userId];
		
		NSLog(@"masterlist: %@", masterList);
		NSLog(@"ID = %d", userID);
	//	[contactFirstLast release];
	}

First Try:

2010-03-06 11:28:21.472 myNetwork[19052:207] userIDsorted: (
"Ant, Adam, 69277408",
"Lehrner, bianca, 69279824",
"lehrner, felicitas, 69275024",
"lehrner, laetitia, 69218320",
"lehrner, stefan, 69309360",
"Stremnitzer, Michael, 69277424"
)

Second Try:

and here are the IDs diefferent:

2010-03-06 11:27:28.361 myNetwork[19013:207] userIDsorted: (
"Ant, Adam, 67196768",
"Lehrner, bianca, 67177328",
"lehrner, felicitas, 67203376",
"lehrner, laetitia, 69210880",
"lehrner, stefan, 67265888",
"Stremnitzer, Michael, 67177312"
)

Is this a behavier of the Simulator? I am trying to extend the addressbook, therefore I would need the correct ID to fill a table with data...

Thanks for your help!

Stefan
StefanL is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,535
Threads: 94,052
Posts: 402,640
Top Poster: BrianSlick (7,979)
Welcome to our newest member, Chayolei001
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:52 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.