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 8698027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:39:15+00:00 2026-06-13T01:39:15+00:00

I am developing a contacts app. I want to add a contact, by opening

  • 0

I am developing a contacts app. I want to add a contact, by opening a new view like this:

RootViewController.m…
it has a NSMutableArray called contacts

- (IBAction)addContact:(id)sender {

    AddContViewController *cont = [[AddContViewController alloc]init];
    [self.navigationController presentViewController:cont animated:YES completion:nil];

}

And then come back and add the contact to the array of the root view controller:

AddContViewController.m

- (IBAction)acceptAction:(id)sender {


    if ([[firstName text] length] < 1 && [[lastName text] length] < 1)
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Oh no!" message:@"Invalid contact information!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [alert show];
    }
    else{

// create the contact and put it in the root view controller’s array

   Contact *cont = [[Contact alloc]initWithFirstName:[firstName text] lastName:[lastName text] andDOB:[dobPicker date]];

// and now I don’t know what to do….

    [self dismissViewControllerAnimated:YES completion:^{
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success!" message:@"Contact added successfully!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [alert show];
        }];
    }
}
  • 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-13T01:39:16+00:00Added an answer on June 13, 2026 at 1:39 am

    There are several ways to pass the data back. I’d suggest setting up a delegate method.
    Add this to the top of your AddContViewController.h after any imports:

    @class addContViewController
    @protocol addContViewControllerDelegate <NSObject>
    -(void)addContViewController:(addContViewController *)controller didAddContact:(Contact *)contact;
    @end
    

    And after the interface section add

    @property (nonatomic, weak) id <addContViewControllerDelegate> delegate;
    

    Then in your RootViewController.h add the protocol to the interface line <addContViewControllerDelegate>
    Now in your RootViewController.m method addContact just before you push the new view, add:

    cont.delegate = self;
    

    Now in your AddContViewController.m instead of dismissing the view, call:

    [self.delegate addContViewController:self didAddContact:cont];
    

    This will call a new method in your RootViewController which it’ll pass the Contact and in here you can do with it want you want, but first dismiss the view:

    -(void)addContViewController:(addContViewController *)controller didAddContact:(Contact *)contact {
    self dismissViewControllerAnimated:YES;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an android chat app and would like to automatically add/synchronize contacts
I am developing an Android application. This app deals with contact information (name, number,
I am developing a app in which I have to add custom contacts to
I am developing app which add contact info to android contact list .to How
I am developing a desktop app which manages contact information and I want to
I'm developing a web app with asp.net mvc 2. This app, has a controller
I'm developing a custom contacts app. I read default Contacts app source from Github
I'm developing an app for Android 2.1 upwards. I want to enable my users
I am developing an Outlook Add-in that is using Outlook contacts from local machine
I'm developing an app for mobile phones that syncs the contacts with the facebook

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.