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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:37:13+00:00 2026-05-15T07:37:13+00:00

I have an UITabBarController with two tabs: UINavigationController OptionsViewController : UIViewController How can I

  • 0

I have an UITabBarController with two tabs:

  1. UINavigationController
  2. OptionsViewController : UIViewController

How can I reach data (ie. UILabel.text) set in OptionsViewController, in a new added modal View which has been invoked from UINavigationController?

Edit1:

Scenario: After launching app I select the second tab bar called “Options” where I fill up a textField. The label is set to value from textField. Next I select first tab bar called “Main” where I have a button. I click the button and new modal View appears. In this new modal View I’d like to show the value from textField

  • 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-15T07:37:14+00:00Added an answer on May 15, 2026 at 7:37 am

    I love MVC, but I’m not an absolute purist to the point of hurting yourself to accomplish a fairly trivial task, so the answers you’ve gotten here are good and useful. However, by creating an ivar to refer back to a specific type such as a label or other view controller, you are coupling things together that aren’t necessary to couple. What you could do instead is make your first tab view controller a delegate of your second tab view controller. So do something like this in your app delegate.

    OptionsViewController *optionsViewController = // ... get this from the tab view
    FirsTabViewController *firstTabViewController = // ... same here
    
    [optionsViewController setDelegate:firsTabViewController];
    

    Which means that you need an ivar in your OptionsViewController:

    @property (assign) id delegate;
    

    Then, when whatever event you want to trigger the change occurs in your options view controller, see if the delegate can respond to a selector you’ve named. For example:

    - (void)someEventHappenedLikeTyping:(id)sender;
    {
        if ([delegate respondsToSelector:@selector(setOptionsString:)]
            [delegate performSelector:@selector(setOptionsString:) withObject:[label text]];
    }
    

    Notice you never specified any specific object types. You just check to see if the delegate (which was declared as id) can respond to that selector. If it can, it does what it’s told and just is silent otherwise.

    For this to work, you need an ivar for the optionsString in your FirstTabViewController and so it would be declared in the header as:

    @property (copy) NSString *optionsString;
    

    and then @synthesize it in the .m. This causes -setOptionsString to become a valid selector that will get called in the -someEventHappenedLikeTyping method.

    Anyhow, now, if you ever need to to change which view controller references which, you don’t have to go into the header and change the type of ivar referenced. You simply need to implement the selector (this is known as an informal protocol, by the way) in the view controller that is a delegate of your options view controller.

    Just some food for thought there. Hope that helps. There is further de-coupling that could be done in the code I’ve added, but again it may be overkill for such a simple task. Let me know if you need clarification or want to understand what I mean by further decoupling.

    Best regards,

    p.s. Sometimes needing to share data between two tab bar view controllers, means you have a design flaw. If you are wanting to store preferences from your options view, you should just call

    [[NSUserDefaults standardUserDefaults] setObject:[label text] forKey:@"option1"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    Then you can pull from the NSUserDefaults back in your main tab with;

    NSString *option1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"option1"];
    // Do something with option1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 440k
  • Answers 440k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're looking for ColorConverter.ConvertFromString. Color color = (Color)ColorConverter.ConvertFromString("#10eeee"); SolidColorBrush myBrush… May 15, 2026 at 5:12 pm
  • Editorial Team
    Editorial Team added an answer Yes, but it's more complex than what you may be… May 15, 2026 at 5:12 pm
  • Editorial Team
    Editorial Team added an answer APC's changelog explicitely mentions PHP 5.3, so it's just an… May 15, 2026 at 5:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.