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