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

  • SEARCH
  • Home
  • 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 6989329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:11:51+00:00 2026-05-27T19:11:51+00:00

I am aware that this topic has been covered already in many places, but

  • 0

I am aware that this topic has been covered already in many places, but while going through the different answers, I could not find a solution that fits my case.

Basically what I am trying to do is very simple. I have a view controller with a table view, and a + button that fires a second view controller where the user can enter, say a name, and this name is then added to the first view controller table view. Think about Contacts on the iPhone where you can add a new person (or Amazon where you can add a new credit card).

My question is – what is the best way to return this string (in this case) back to the view controller where the table is?

People suggested using NSDefaults, Delegate, or singleton none of which are really good for this case (each one for its own reason). I really just need to return a simple string.

Thank you for your help.

  • 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-05-27T19:11:51+00:00Added an answer on May 27, 2026 at 7:11 pm

    Here’s what you need to do (please note I am typing this off the top of my head so the compiler may have some issues with my syntax).

    In your child view controller interface:

    @protocol ChildDelegate <NSObject>
    - (void)didConfirmName:(NSString*)name
    @end
    
    @interface ChildViewController : UIViewController
    ...
    
    @property (nonatomic, assign) id<ChildDelegate> delegate;
    

    And implementation, inside the method called when the user confirms whatever they need to confirm:

    - (void)myCustoMethod
    {
        ...
        if ([self.delegate respondsToSelector:@selector(didConfirmName:)])
            [self.delegate didConfirmName:NAME_STRING];
    }
    

    And in your parent view controller, when you are instantiating the child view controller, assign SELF as the delegate:

    ChildViewController *vc = [[ChildViewController alloc] init...];
    vc.delegate = self;
    

    And implement:

    - (void)didConfirmName:(NSString*)name
    {
        // Do whatever you want with the name here...
    }
    

    Also make sure you tell the compiler that you are implementing the protocol :

    @interface ParentViewController () <ChildDelegate>
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm aware that MD5 has had some collisions but this is more of a
I am aware this topic has been raised severals, however i have a slight
I'm aware that there is another similar question on this topic, but personally I
I aware that this will be a less programming question, but still... How can
I'm aware that this is possible with the os module's os.system(color) function, but this
I am aware that a thousand and one questions relating to this topic have
I'm aware that there are a LOT of posts on this topic, however no
I am aware that there are probably other questions regarding this topic. I guess
I'm aware of other posts on this topic but I'm only really one rung
I understand that this is an insanely broad topic, but can anyone give me

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.