views:

158

answers:

2

I'm trying to build a application that allows the user to either A) enter a new person, or B) select a person from their contacts... My question is on item B. I've read briefly about loading Modal view controllers, but, was hoping someone could point me in the direction of a tutorial or article talking specifically about that kind of use case scenario.

Yes, I am also somewhat new to iPhone application development.

A: 

Just to update everyone (and please correct me if I am going about this improperly), I've found this resource: http://developer.apple.com/iphone/library/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/100-Introduction/Introduction.html

Ixmatus
+1  A: 
  1. Your view controller should implement ABPeoplePickerNavigationControllerDelegate protocol
  2. You show the peoplepicker something like:
    ABPeoplePickerNavigationController *peoplePickerController =
    [[ABPeoplePickerNavigationController alloc] init];
    peoplePickerController.peoplePickerDelegate = self;

    [self presentModalViewController:peoplePickerController animated:YES];

    [peoplePickerController release];
3. And you might want to implement the optional methods as:

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
    [self dismissModalViewControllerAnimated:YES];
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
    NSString *name = (NSString *)ABRecordCopyCompositeName(person);
    // do something with name.. and release

    [self dismissModalViewControllerAnimated:YES];    

    return NO;
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    return NO;
}
Prakash
Yes, thank you for this answer - I found someone that had implemented this exact set of methods.Just what I needed.
Ixmatus