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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:17:58+00:00 2026-06-05T12:17:58+00:00

I created a singleton called GCTurnBasedMatchHelper, which includes the following code in the header:

  • 0

I created a singleton called “GCTurnBasedMatchHelper”, which includes the following code in the header:

@property (nonatomic, retain) NSString *pick1;

In the implementation I have these lines:

#import "GCTurnBasedMatchHelper.h"
//Some implementation code in here...
@synthesize pick1;

- (void) pick{
int r = arc4random() % 2;
if (r==0) {
    pick1 =[[NSString alloc] initWithFormat:@"Askerer"];
    NSLog(@"%@", pick1);
} else {
    pick1 =[[NSString alloc] initWithFormat:@"Answerer"];
    NSLog(@"%@", pick1);
    }
}

How can I access the value of pick1 from another class implementation ViewController.m?
And how can I access other properties from ViewController.m in GCTurnBasedMatchHelper.m?

Thanks!

  • 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-05T12:18:01+00:00Added an answer on June 5, 2026 at 12:18 pm

    You can access the properties of your Singleton class from ViewController.m by doing something such as this:

    [[GCTurnBasedMatchHelper sharedInstance] pick1];
    

    Assuming, -sharedInstance is what the initialization method is for your Singleton, i.e:

    +(GCTurnBasedMatchHelper*)sharedInstance {
    
       //Singleton setup here
    
    }
    

    The tricker bit, is Accessing properties that’re in ViewController.m from your Singleton. I’d recommend creating a Data Source or Delegate for your Singleton that returns your desired properties.

       -(NSMutableArray*)viewControllerProperty {
    
            return self.myViewControllerPropertyArray;
    
      }
    

    Assuming -viewControllerProperty is a Delegate method for your singleton. In your singleton, you can now access ViewController class properties by invoking this from your singleton.

    [self.delegate viewControllerProperty];
    

    Of course, I didn’t show creating and or setting the delegate, nor none of the other obvious stuff like @synthesizing. I take it you can figure this out, as it’s not in the scope of your question.

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

Sidebar

Related Questions

I created a Singleton class in c#, with a public property that I want
My app has a singleton class called CycleManager. I have created a sealed class
I have created the following Singleton in my iPhone app: #import AppManager.h static AppManager
I'm using the following code in a singleton remoting object MBRO. This function is
I've created a singleton which in the constructor goes like this: public static class
We have a lot of class code which has some boilerplate like the following:
I've created a singleton class that loads a plist. I keep getting this error
I have created a singleton class to keep track of my data on my
I am trying to access the singleton instance created by my WCF service but
I've created a system where i can request an NSManagedObjectContext from a singleton object,

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.