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

  • Home
  • SEARCH
  • 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 172021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:05:29+00:00 2026-05-11T13:05:29+00:00

I am developing an iPhone application using Objective-C. I want to access a data

  • 0

I am developing an iPhone application using Objective-C. I want to access a data member which is of type NSMutableArray of the RootViewController class in another class. I tried making the array static. But I would like to have a non static array. How do I achieve this?

  • 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. 2026-05-11T13:05:30+00:00Added an answer on May 11, 2026 at 1:05 pm

    You need two things:

    1. a reference to the RootViewController
    2. a means of getting your variable out of RootViewController.

    In a situation where you have (most likely) one RootViewController per application, it makes sense to keep a reference to that object in your application’s delegate. You can get the app delegate like this:

    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 

    In your app delegate class you should add a property called rootViewController that exposes your RootViewController object. Now you can write things like

    RootViewController *theRootViewController = appDelegate.rootViewController; 

    This satisfies the first requirement. Now, in order to access the object owned by the view controller, you’ll need to add a property to RootViewController. You didn’t really say what the object is or does, so let’s just call it myMutableArray. Create a readonly property with that name on RootViewController, and now you’ll be able to write things like this:

    NSMutableArray *myArray = theRootViewController.myMutableArray; 

    This will let you do what you want to do.

    I have to warn you, though: exposing an NSMutableArray is generally not a great idea. The reason is that if you change the contents of that array, RootViewController will have no idea that you’ve done this. So if you were creating, say, a master-detail view, your RootViewController would not know that you’ve added a new object.

    It would be better if you wrote methods that let RootViewController modify the array internally. For example, you could have a method named addFooObject: that manages the array. Then the view controller will know what you’ve done to it. For access, you could very easily return an immutable, autoreleased copy of the mutable array from your property.

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

Sidebar

Ask A Question

Stats

  • Questions 167k
  • Answers 167k
  • 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 StreamReader is designed for reading character data. You should use… May 12, 2026 at 1:27 pm
  • Editorial Team
    Editorial Team added an answer I strongly recommend WWWSQLDesigner to design your database. Guideline that… May 12, 2026 at 1:27 pm
  • Editorial Team
    Editorial Team added an answer Since you are using object literals on your previous question,… May 12, 2026 at 1:27 pm

Related Questions

I am planning to make an iPhone web application and I just wanted to
I've got an iPhone app I'm developing and when the app launches I open
I am thinking about buying an iPod touch to make some money on developing
I am developing an iPhone application that persists data to a SQLite3 database. For

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.