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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:11:48+00:00 2026-06-16T13:11:48+00:00

Possible Duplicate: dismissModalViewController AND pass data back I’m new to ios development and stuck

  • 0

Possible Duplicate:
dismissModalViewController AND pass data back

I’m new to ios development and stuck on this problem:

I’m using storyboarding and have a navigation controller, vcA, with a TableView in it which shows some data from a MutableArray (which is initialized in viewdidload of the same class). After selecting any cell, a second view controller, vcB, is shown with a TextField in it and a button called “Add to list”.

What I want is that when I enter some text in the TextField and press the “Add to list” button the text should be added to the array of previous view (which gets shown in the TableView) and when i tap the “Back” button on vcB‘s navigation bar, vcA should show the updated TableView with the new entry in it (on the top of list). Basically I want to add the text from vcB‘s TextField to the array of vcA and show the new array after clicking the BACK button.

I have searched a lot about this issue and seem to find that delegate and protocols is the way to achieve the desired result but I’m having trouble understanding delegation.

  • 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-16T13:11:49+00:00Added an answer on June 16, 2026 at 1:11 pm

    I have the second view controller presenting itself as modal in this example:

    In the second view controllers h file:

    @protocol SecondViewControllerDelegate <NSObject>
    - (void)addItemViewController:(id)controller didFinishEnteringItem:(NSString *)item;
    @end
    
    @interface SecondPageViewController : UIViewController <UITextViewDelegate>
    {
         NSString *previouslyTypedInformation;
    }
    
    @property (weak, nonatomic) IBOutlet UITextView *textView;
    @property (nonatomic) NSString *previouslyTypedInformation;
    @property (nonatomic, weak) id <SecondViewControllerDelegate> delegate;
    

    In the second view controllers m file make sure to synthesize properties and add then add this:

    - (IBAction)done:(id)sender
    {
         NSString *itemToPassBack = self.textView.text;
         NSLog(@"returning: %@",itemToPassBack);
         [self.delegate addItemViewController:self didFinishEnteringItem:itemToPassBack];
         //dismiss modal view controller here
    }
    

    Then in the first view controllers h file set it as delegate:

     @interface FirstPageViewController: UIViewController <SecondViewControllerDelegate>
     @property (nonatomic) NSString *returnedItem;
    

    Then in the first view controller’s m file synthesize and add the method:

    - (void)addItemViewController:(SecondPageViewController *)controller didFinishEnteringItem:    (NSString *)item
    {
        //using delegate method, get data back from second page view controller and set it to property declared in here
        NSLog(@"This was returned from secondPageViewController: %@",item);
        self.returnedItem=item;
    
        //add item to array here and call reload
    }
    

    Now you have the text of what was returned! You can add the string to your array in the first view controller’s viewDidLoad and call

    [self.tableView reloadData]; 
    

    and it should work.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: How to add dynamically a combobox using jQuery Look, I've this working
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: Python : how to append new elements in a list of list?
Possible Duplicate: When does Endianness become a factor? reading this tuto on endianess, i
Possible Duplicate: How to convert text to unicode code point like \u0054\u0068\u0069\u0073 using php?
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
Possible Duplicate: Remove close button on jQueryUI Dialog? I am getting some problem to

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.