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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:06:35+00:00 2026-05-16T12:06:35+00:00

I want to display some data on table, let’s call it TabeView app. So

  • 0

I want to display some data on table, let’s call it “TabeView” app.

So I created a “navigation-based” application on XCode and it gives me 4 files in the “classes folder”.

  • RootViewController.h
  • RootViewController.m
  • TableViewAppDelegate.h
  • TableViewAppDelegate.m

Now, I wanted to set up the data in TableViewAppDelegate using the “didFinishLaunchingWithOptions” method, which I did using an array.

Then, I need to “send” this array to the RootViewController. I have an array variable in RootViewController so I assume that I need to “set” the array variable in RootViewController from the TableViewAppDelegate. How can I do this?

The problem I am having is, that I don’t know how to set the array variable in RootViewController from TableViewAppDelegate. I want to know if something like below is possible

....
[RootViewController setMyArray:myArray];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
....

But I have no idea how to call “RootViewController”.

Hopefully I made some sense. Thank you.

  • 1 1 Answer
  • 1 View
  • 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-16T12:06:36+00:00Added an answer on May 16, 2026 at 12:06 pm

    First, create a property in your RootViewController class for the array variable. So e.g. if your array variable is called myArray your code might look something like this:

    In RootViewController.h:

    #import <UIKit/UIKit.h>
    
    @interface RootViewController : UITableViewController {
        NSArray *myArray;
    }
    
    @property (nonatomic, retain) NSArray *myArray;
    
    @end
    

    and add the corresponding @synthesize line in RootViewController.m:

    #import "RootViewController.h"
    
    @implementation RootViewController
    
    @synthesize myArray;
    
    // methods here
    
    @end
    

    Now you can set the myArray member of a RootViewController object like this:

    myRootViewController.myArray = [NSArray arrayWithObjects:@"foo", @"bar", nil]; 
    

    Now, in your app delegate class, you can use the viewControllers property of self.navigationController to return the view controllers in the navigation stack. The root controller will always be at index 0. viewControllers will return an NSArray, whose elements are of type NSObject, so you need to cast to a RootViewController pointer too. Here it is in two lines, to make the cast explicit:

    // get a pointer to the root view controller
    id obj = [self.navigationController.viewControllers objectAtIndex:0];
    
    // cast it to a RootViewController pointer
    RootViewController* rvc = (RootViewController*)obj;
    
    // Now you can set the array
    rvc.myArray = someArray;
    

    (In order to use the RootViewController class name in your app delegate class you’ll need to import the relevant header file – put this at the top of TableViewAppDelegate.m:

    #import "RootViewController.h"
    

    And that’s it!

    p.s. Bear in mind that declaring your myArray property as type (nonatomic, retain) means that your RootViewController object will end up pointing to the same instance of NSArray that you pass to it. So, for example:

    NSMutableArray *array = [NSMutableArray arrayWithObjects: @"foo", @"bar", nil];
    myRootViewController.myArray = array;
    
    [array removeAllObjects]; // myRootViewController.myArray is now empty!
    

    You can use (nonatomic, copy) instead, in which case your RootViewController object will make a copy of the array you pass in and retain that instead. Changes to the array once you’ve assigned it to your RootViewController object won’t affect the copy.

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

Sidebar

Related Questions

Hey guys, I have an application that I want to display some data from
I have a JTable that I want to use to display some data (a
i have two foreach loop to display some data, but i want to use
I have some data that I want to display as a box plot using
I want to display and edit some objects in a WPF data grid and
In my app,I want to display some information in the middle of the screen
I need to display some data on a browser but I want to split
I have some hierarchical data that I need display as a table, can I
I'm trying to select a nested table to display some tabular data using jQuery
My C# coded application uses an Infragistics.Win.UltraWinGrid.UltraGrid to display some data. The data is

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.