Return Selected Phone Address from iPhone Address Book

Posted by Ali on Stack Overflow See other posts from Stack Overflow or by Ali
Published on 2010-03-25T16:18:35Z Indexed on 2010/03/25 16:23 UTC
Read the original article Hit count: 534

Hey,

I found a tutorial online that extends that Apple QuickStart Application which is the basic Address Book Application and another that returns the first phone number regardless of what phone number was clicked. I want to display only the selected phone number in the label. The label is called phoneNumber:

- (BOOL)peoplePickerNavigationController:

(ABPeoplePickerNavigationController *)peoplePicker

  shouldContinueAfterSelectingPerson:(ABRecordRef)person

                            property:(ABPropertyID)property

                          identifier:(ABMultiValueIdentifier)identifier{


ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSMutableArray *phones = [[NSMutableArray alloc] init];
int i;
for (i = 0; i < ABMultiValueGetCount(phoneMulti); i++) {
NSString *aPhone = [(NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, i)autorelease];

    [phones addObject:aPhone];
}

NSString *mobileNo = [phones objectAtIndex:0];
self.phoneNumber.text = phones;

[self dismissModalViewControllerAnimated:YES];

return NO;

}

How do I ensure that the label is the one selected by the user and not just the first array entry(or any other array entry i code in)

Thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk