Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:02:21+00:00 2026-06-13T18:02:21+00:00

I am working on a AddressBook project, One of my requirement is While adding

  • 0

I am working on a AddressBook project, One of my requirement is While adding new Contacts manually using my application it should check whether “Organization field” value is entered by user/not.

I have Add(+) button on my Navigation Bar with d following code snippet:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self 
action:@selector(add:)];
self.navigationItem.rightBarButtonItem = addButton;

A present modal view appears on clicking this add button, by native Address Book;

-(void)add:(id)sender
{
    ABNewPersonViewController *view = [[ABNewPersonViewController alloc] init];
    view.newPersonViewDelegate = self;
    UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:view];
    [self presentModalViewController:newNavigationController animated:YES];
}

- (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person
{
    newPersonView.displayedPerson = person;
    [self dismissModalViewControllerAnimated:YES];
    [table reloadData];
}

Before contact is saved to my address Book i want to check if the user has added “Organization field” or not. In case of blank/nil i want to show a Alert Box asking for filling Organization value. It is mandatory, once user provides Organization value then contact would be saved to AddressBook.

EDIT: As suggested below by Fabio, i updated my codes..

- (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person{

NSString *company = [NSString stringWithFormat: @"%@", ABRecordCopyValue(person, kABPersonOrganizationProperty)];
if ([company isEqualToString: @"(null)"]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Value Required!" message:@"Please provide some value for ORGANIZATION Field..." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}
else
{
 newPersonView.displayedPerson = person;
 [self dismissModalViewControllerAnimated:YES];
}
}

With this i am able to show an Alert to the user to provide field value. It is also updating the subsequent record created. But, as the MODAL VIEW is Dismissed, the Detailed view(Info screen of Native App) shows no information about the contact.

Also, CANCEL Button doesn’t works in its regular way.. i can’t go back to app, as it repeatedly ask to provide field value, even if i provide and press cancel.

Can any one guide me!

Thanks & Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:02:22+00:00Added an answer on June 13, 2026 at 6:02 pm

    There is no documented way to do this using ABNewPersonViewController, because when the delegate method is called, the person is already saved by the ABNewPersonViewController.
    Formerly you should made your own “insert controller” and use it.

    But I tried this workaround and obtained this behavior (on iOS 6):

    in the delegate method

    - (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person
    

    you receive a ref to the new person created.
    You can then access to the person saved and check if the company has been compiled. If not, simply you don’t call

    [self dismissModalViewControllerAnimated:YES];
    

    The ABNewPersonViewController will stay in position, and you can show an alert to the user asking him to compile the company.
    The fields will remain compiled and ABNewPersonViewController “linked” to the new user created.

    Then, the user can:

    • compile the company field –> a tap on Save will update the saved person and give your delegate new data, so you can dismiss the viewcontroller correctly
    • tap cancel –> you receive the cancel, and the person is deleted by the ABNewPersonViewController itself

    But…because I can’t find this behavior documented in any place, I’m not sure if

    • it will work on other versions
    • it will “survive” to the review process (formerly you are not using private API, but not sure if “not closing” the viewcontroller when the user taps save is not good for the UI Guidelines)

    Regards
    Fabio

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how
in an application I'm working on, I need to interact with iPhone's AddressBook. Currently,
I am working in an iPhone application which uses adding contact to the address
Hi im working on iphone application using monotouch im trying to get list of
I have made a birthday reminder application using localNotification. It read the contacts from
Working on a small game using an HTML5 canvas, and javascript. And it's working
Working on the problems on Project Euler to try to learn Clojure. I'm on
I've been working this issue for a while now and I am open to
I am deleting contacts from addressbook programmatically. I got error There's already an instance
i am working on one app and in that i have to open the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.