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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:45:06+00:00 2026-05-26T21:45:06+00:00

I have a RootViewController and a DetailViewController where I am trying to pass a

  • 0

I have a RootViewController and a DetailViewController where I am trying to pass a NSMutableArray from the rootView to the detailView. I have created an object of the RootViewController inside the DetailViewController and accessing it like the following

RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

detailViewArray = [root.rootViewArray copy];

Note: Both the arrays are declared in the .h files; synthesized and then allocated and initialized array = [[NSMutableArray alloc] init];

Problem: I am not too sure why it still doesn’t work. I have tried a lot of the solutions on the internet but it didn’t quite work for me. The property for the root array is nonatomic, retain Is it something wrong with that? Do I need to change it to something or the method I am following is just not right.. Please if someone could 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-26T21:45:07+00:00Added an answer on May 26, 2026 at 9:45 pm

    If you alloc/init the RootViewController inside the DetailViewController, you are creating another instance of the RootViewController. You are not getting the same instance (with data) of the rootViewController.

    That said, even passing a reference of a viewController to another viewController to then poke at it’s data is sort of bad. It creates tight coupling between the views.

    Instead, if you need to get data, consider using a delegate to communicate between the views.

    What exactly does delegate do in xcode ios project?

    Tutorial:

    http://www.theappcodeblog.com/2011/04/15/passing-data-between-views-tutorial-using-a-protocol-delegate-in-your-iphone-app/

    Another option is to create a shared model (read up on model view controller patterns). It’s typical in that pattern to create a model and share data by getting a singleton instance of your model:

    MyModel *model = [MyModel sharedInstance];
    

    Then, each view can set and read data from that same (singleton) instance of the model.

    Which to choose? The model is better if many views share the same data. A delegate is appropriate for a couple views to communicate with each via callbacks.

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

Sidebar

Related Questions

Trying to [self.parentViewController.tableView reloadData] from a save: method in my DetailViewController but getting my
Well, I have a TableView in a RootViewController with a DetailViewController for the display
I have a spliviewcontroller based ipad application. When the tableviewcell is selected from rootviewcontroller
I am new in iPhone development and Objective-C. I have RootViewController and DetailViewController. I
I have a XIB (RootViewController) that has actions I want to do from a
I have splitview and it contains rootviewcontroller(uitableviewcontroller subclass) and detailview(viewcontroller subclass). Now I have
I have a RootViewController and a SubViewController. I traverse the views in either direction.
I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have
I have this button on the leftside of my UISplitViewController (RootViewController) that has a
I have a generic UISplitViewController (UITableView in the RootViewController and other stuff in the

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.