Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Write this piece of code in <code>navigation controller.m</code>:</p> <pre><code>ABAddressBookRef addressBook= ABAddressBookCreate(); // this will open the AddressBook of the iPhone CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook); // this copies all the contacts from the Address Book into the array NSString *contactName = [[NSString alloc] init]; // specify the contact name to be edited contactName = @"ABCD"; for (int i =0 ;i&lt;ABAddressBookGetPersonCount(addressBook);i++){ ABRecordRef ref = CFArrayGetValueAtIndex(people, i); NSString *firstName = (NSString *)ABRecordCopyValue(ref,kABPersonFirstNameProperty); // this gets the First Name of the person // check whether the editable contact exists in the AddressBook if exists then allows the user to edit the contact if ([contactName compare: firstName] == NSOrderedSame) { ABPersonViewController *personController = [[ABPersonViewController alloc] init]; personController.addressBook = addressBook; // this passes the reference of the Address Book personController.displayedPerson = ref; // this sets the person reference personController.allowsEditing = YES; // this allows the user to edit the details personController.personViewDelegate = self; personController.navigationItem.rightBarButtonItem = [self editButtonItem]; // this will add the inbuilt Edit button to the view // this displays the contact with the details and presents with an Edit button [[self navigationController] pushViewController:personController animated:YES]; [personController release]; } } // setEditing method needs to be overridden for edit functionality to work properly ------------------ - (void)setEditing:(BOOL)flag animated:(BOOL)animated { [super setEditing:flag animated:animated]; if (flag == YES){ // change the view to an editable view [ [self navigationController] setEditing:YES animated:NO]; } else { // save the changes and change the view to noneditable [ [self navigationController] setEditing:NO animated:NO]; } } - (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue { return YES; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload