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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:46:44+00:00 2026-05-31T21:46:44+00:00

for iOS 5.0 using ARC, here is something I want to implement and need

  • 0

for iOS 5.0 using ARC, here is something I want to implement and need direction on how it can be best done. I have some global settings that determine the state of each object in the object tree. I need this to be just one instance shared by all objects and their children so that on changing the settings, the behaviour of these objects change as well… to make it clear, its something like this..

                       Global Settings (current language)
                               |(should affect)
                    ---------------------------- 
                    |                          |
                 GenericParent1            GenericParent2
                    |                          |
              ------------
              |          |
          ChildType1    ChildType2
  • 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-31T21:46:46+00:00Added an answer on May 31, 2026 at 9:46 pm

    While borrden answer is correct, (singletons are used in case you want to make sure you have only one instance runing) the implementation should be something like this:

    +(MyClass *)singleton {
     static dispatch_once_t pred;
     static MyClass *shared = nil;
    
     dispatch_once(&pred, ^{
      shared = [[MyClass alloc] init];
     });
     return shared;
    }
    

    So that you can take advantage of the grand central dispatch.

    You can read more about this here: http://cocoasamurai.blogspot.jp/2011/04/singletons-your-doing-them-wrong.html

    Edit:

    With static implementation, do you mean something like global variables? If i understand correctly you want to “share” a state between 2 or more instances that come from the same parent. However each instance has its own local variables and those inherited, but still the inherited ones are specific for THAT instance. If you want to share a state between these objects you need something global to communicate. For example, if you want to share an object between 2 instances you have to make their pointers point to the same object, then you can read the “state” saved in that object for both and if you change it from one place it will change from the other. The problem with this is that you cannot ensure you will only have one instance of that object. You might even by mistake create more than one and be accessing a different one on your methods. This is what a singleton solves, even if you try creating a new one you will just get the original.

    Alternatively you can have a global variable and share information trough that. but that approach is not very well looked upon, because it makes your code a little hard to understand sometimes.

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

Sidebar

Related Questions

What is the lowest iOS version I can build for while using (ARC)? I'm
I'm integrating my iOS app with Twitter, and I am using ARC. I can
I'm using ARC in an iOS app i'm building. I've created some objects, in
I have started using (ARC) with iOS 5, but I have a problem which
I have a iOS project in which I am using ARC in my own
for an iOS 5.0 application using ARC, i have an NSArray of objects that
What is the best way to generate random numbers using Objective-C on iOS? If
I'm developing a large scale application for iOS 5 using ARC in xcode. The
I'm using ARC and targeting iOS 5. I've declared an NSMutableArray ivar in one
This project is for iPhone with iOS 5 using ARC and Core Data. All

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.