/ Published in: Objective C
Function to retrieve contact data from iPhone.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
-(void)retrieveContactList { ABAddressBookRef myAddressBook = ABAddressBookCreate(); for (id record in allPeople) { CFTypeRef phoneProperty = ABRecordCopyValue((ABRecordRef)record, kABPersonPhoneProperty); //NSLog(@"phones array: %@", phones); CFRelease(phoneProperty); [newRecord setObject:contactName forKey:@"name"]; //[contactName release]; //NSString *fieldData = [NSString stringWithFormat:@"%@: %@", contactName, phone]; if(![newPhone isEqualToString:@""]) [newPhone appendString:@", "]; [newPhone appendString:phone]; } [newRecord setObject:newPhone forKey:@"phone"]; [newPhone release]; [phones release]; [contactList addObject:newRecord]; //[newPhone release]; } CFRelease(myAddressBook); // NSLog(@"Final data: %@", contactList); }