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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:14:51+00:00 2026-06-01T15:14:51+00:00

I have created a singleton class to keep track of my data on my

  • 0

I have created a singleton class to keep track of my data on my iPhone app. I know singleton’s only need to be instantiated once, but what is the best place to instantiate it? Should this be done in the appDelegate? I want to be able to call this singleton (which contains an NSMutableArray) from a multitude of classes so that I can have access to the array.

Here is my Class I wrote:

#import "WorkoutManager.h"

static WorkoutManager *workoutManagerInstance;

@implementation WorkoutManager
@synthesize workouts;

+(WorkoutManager*)sharedInstance {
    if(!workoutManagerInstance) {
        workoutManagerInstance = [[WorkoutManager alloc] init];
    }
    return workoutManagerInstance;
}

-(id)init {
    self = [super init];
    if (self) {
        workouts = [[NSMutableArray alloc] init];
    }
    return self;
}

@end
  • 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-06-01T15:14:53+00:00Added an answer on June 1, 2026 at 3:14 pm

    In almost all cases, the point of a singleton is you don’t care who first instantiates it. Whoever is the first to call [Something sharedSomething] will be the creator. You want to use the pattern given in ” How do I implement an Objective-C singleton that is compatible with ARC? ” It’ll ensure the singleton is created only one time.

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

Sidebar

Related Questions

My app has a singleton class called CycleManager. I have created a sealed class
Actually i have created an singleton class. Now my singleton class extends Activity, and
Using FluentNHibernate in a web application, I've created a singleton SessionFactory class to have
I want to have singleton class that its object is not statically created. having
Basically I have a class which an instance of is created via a Singleton
I have created a Registry class in .NET which is a singleton. Apparently this
I have a singleton class which I would like to be created using Spring's
i have created a simple public ref class in the vc++ project, which is
i created a singleton class and trying to access that class in other class
I have created simple example with @Singleton, @Schedule and @Timeout annotations to try if

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.