i am developing contact list app so that i need to bring the contact data and stored in the tableview i did as below
- (void)listPeopleInAddressBook:(ABAddressBookRef)addressBook
{
NSInteger numberOfPeople = ABAddressBookGetPersonCount(addressBook);
contactList= CFBridgingRelease(ABAddressBookCopyArrayOfAllPeople(addressBook));
for (int i = 0; i < numberOfPeople; i++)
{
ABRecordRef person = (__bridge ABRecordRef)contactList[i];
firstName = CFBridgingRelease(ABRecordCopyValue(person, kABPersonFirstNameProperty));
lastName = CFBridgingRelease(ABRecordCopyValue(person, kABPersonLastNameProperty));
NSLog(@"Name:%@ %@", firstName, lastName);
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFIndex numberOfPhoneNumbers = ABMultiValueGetCount(phoneNumbers);
for (CFIndex i = 0; i < numberOfPhoneNumbers; i++)
{
NSString *phoneNumber = CFBridgingRelease(ABMultiValueCopyValueAtIndex(phoneNumbers, i));
NSLog(@" phone is:%@", phoneNumber);
}
CFRelease(phoneNumbers);
}
}
aim getting the data in the strings format that is first name and the last name .my problem is i need to save the data that is present in first name and last name to array But that array is present out side of the for loop . so that i will pass the array data to the table view .