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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:39:37+00:00 2026-06-08T12:39:37+00:00

I am trying to use singleton in my app. I want to share 8

  • 0

I am trying to use singleton in my app. I want to share 8 strings using a singleton.

This is the tutorial I referred to -> http://www.galloway.me.uk/tutorials/singleton-classes/

My code:
– MyManager.h

#import <foundation/Foundation.h>

@interface MyManager : NSObject {
NSString *someProperty1;
NSString *someProperty2;
NSString *someProperty3;
NSString *someProperty4;
NSString *someProperty5;
NSString *someProperty6;
NSString *someProperty7;
NSString *someProperty8;
}

@property (nonatomic, retain) NSString *someProperty1;
@property (nonatomic, retain) NSString *someProperty2;
@property (nonatomic, retain) NSString *someProperty3;
@property (nonatomic, retain) NSString *someProperty4;
@property (nonatomic, retain) NSString *someProperty5;
@property (nonatomic, retain) NSString *someProperty6;
@property (nonatomic, retain) NSString *someProperty7;
@property (nonatomic, retain) NSString *someProperty8;

+ (id)sharedManager;

@end

MyManager.m

#import "MyManager.h"

@implementation MyManager

@synthesize someProperty;

#pragma mark Singleton Methods

+ (id)sharedManager {
static MyManager *sharedMyManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}

- (id)init {
  if (self = [super init]) {
someProperty1 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty2 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty3 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty4 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty5 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty6 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty7 = [[NSString alloc] initWithString:@"Default Property Value"];
someProperty8 = [[NSString alloc] initWithString:@"Default Property Value"];
  }
  return self;
}

- (void)dealloc {
// Should never be called, but just here for clarity really.
}

@end

I want to use this singleton to use these string variables to add string in one other view and then use it to store in database in another third view.

Can someone please tell me how to reference them and store string in these variables and again access them in the third different view?

  • 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-08T12:39:39+00:00Added an answer on June 8, 2026 at 12:39 pm
    1. import MyManager.h where you use singleton.
    2. [[MyManager sharedManager] setSomeProperty1:@abc"]; //for setting
    3. [[MyManager sharedManager] someProperty1]; // for getting

    or you can use like this also

    MyManager *manager = [MyManager sharedManager];
    manager.someProperty1 = @"abc";
    NSString *str = manager.someProperty1; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying to integrate AdWhirl into my iPhone app using an AppDelegate singleton
I am trying to use a singleton to store variables that will be used
I'm trying to use Google Guice with the @Inject and @Singleton properties as follows:
I'm trying to work out the correct pattern to use for a Singleton that
I am trying use a Java Uploader in a ROR app (for its ease
Using Google app engine, is it possible to initialize a globally accessible singleton on
I'm trying to build site using OOP in PHP. Everyone is talking about Singleton,
I am trying to use the singleton method to access a global object (in
I'm trying to unit-test some classes that make use of a Singleton class whose

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.