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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:08:46+00:00 2026-05-26T20:08:46+00:00

I am trying to pass variable values between classes of different views. I am

  • 0

I am trying to pass variable values between classes of different views.
I am using navigation controller and passing views from one navigation controller to another is possible via declaring property and synthesizing.

However, I do not know how can I do that from one view to not NEXT view but other views in the stack.

For example,

FirstViewController -> SecondViewController -> ThirdViewController

This is the sequence of views in navigation controller.

I want to pass a variable value in FirstViewController to ThirdViewController.

How can I do that?

I tried in the FirstViewController something like that:

SecondViewController *second [SecondViewController alloc] init] autorelease];    
ThirdViewController *third = [ThirdViewController alloc] init] autorelease];  
third.passVariable = myVariable;

.....
[[self.navigationController pushViewController:second animated:YES];
....

How can I do that? can anyone provide me some example code lines?

Many thanks in advance..

  • 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-26T20:08:47+00:00Added an answer on May 26, 2026 at 8:08 pm

    I presume it doesn’t work because you are passing the variable to the third view controller, but pushing the second view controller. Although the third view controller is created, it is autoreleased before the second view controller can push the third view controller.

    Your approach is correct, but what you should do is pass the variable to the second view controller, and when the second view controller creates the third view controller it can pass it to that.

    Edited after comment

    Delegation (which is where you use a protocol) is a way of getting information back to a controller. i.e. if you want to return information back to the first View controller from the third view controller. I wrote a simple example here. But, to set the first view controller as the delegate of the third view controller, you still need to pass a reference to the first view controller up the stack in the same way as I’ve described above.

    If you want to see how to set up a singleton data source, create an iOS project with Core Data and see how the template sets up the managed object context.

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

Sidebar

Related Questions

I am trying to pass one variable to a jQuery function inline (i.e.: using
I'm trying to pass some values from one .aspx page to an handler (.ashx).
I am trying to pass a variable to a Selenium PHPUnit script using the
I'm trying to pass messages between 2 threads using a queue, but I haven't
I'm trying to pass a JavaScript variable to the server-side using jquery.ajax method. I'm
Quick question, I'm trying to pass a value to a variable and then run
I'm trying to pass a variable through a ssh connection, like this: working_dir=/home/user/some_dir/ ssh
I am trying to pass a variable to an ajax request via jquery. I
I am trying to pass a variable PIN2 that I am retrieving like below
i am trying to pass in a selector into the ID variable but this

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.