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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:26:12+00:00 2026-06-01T10:26:12+00:00

I have a static instance variable that is being used throughout my application. It

  • 0

I have a static instance variable that is being used throughout my application. It has properties. These properties are used through my application and seem to work pretty well. However, sometimes the properties are released prematurely. What is odd is that the object that is pulling these properties keeps some and releases others. What would be a good way to insure that the properties of my object are not released prematurely.

Edit: It turns out that the issue was not premature releasing at all. It was a conversion issue. Thanks all for help.

@interface Game : NSObject

@property (nonatomic, strong) PFObject     *gameObject;
//@property (nonatomic, strong) Concept     *concept; // Will need to add Concept Object to GameObject once it's wrapper is done
@property (nonatomic, strong) User         *initialPlayer;
@property (nonatomic, strong) User         *invitedPlayer;         
@property (nonatomic, strong) User         *lastPlayedPlayer;
@property (nonatomic, strong) NSDate       *lastPlayedDate;
@property (nonatomic, strong) NSDate       *timeOutDate;
@property (nonatomic, assign) int           timerTicks;
@property (nonatomic, assign) int           currentRoundNumber;
@property (nonatomic, strong) User          *winnerPlayer;         
@property (nonatomic, assign) int           initialPlayerPoints;
@property (nonatomic, assign) int           invitedPlayerPoints;
@property (nonatomic, assign) int           currentPlayerPoints;
@property (nonatomic, assign) GameStatus    status;
@property (nonatomic, assign) int           initialPlayerTimeouts;
@property (nonatomic, assign) int           invitedPlayerTimeouts;
@property (nonatomic, assign) BOOL          isInitialPlayer;
@property (nonatomic, strong) NSMutableDictionary *rounds;
@property (nonatomic, strong, readonly)     Round *currentRound;

+(void)getActiveUserGameObjects:(PFUser *)user target:(id)target selector:(SEL)selector;
+(void)getYourTurnGameObjects:(PFUser *)user target:(id)target selector:(SEL)selector;
+(void)getTheirTurnGameObjects:(PFUser *)user target:(id)target selector:(SEL)selector;
+(void)getGameObjects:(PFUser *)user yourTurn:(id)yourTurn target:(id)target selector:(SEL)selector;

+(Game*)currentGame;
+(void)setCurrentGame:(Game*)currentGame;

..

//.m @implementation   
..

static Game *sharedInstance = nil;
..


+(Game*)currentGame
{
    return sharedInstance;
}

+(void)setCurrentGame:(Game*)currentGame
{
    sharedInstance = currentGame;
}


...

#pragma mark - Player Setters and Getters

-(void)setInvitedPlayer:(User *)invitedPlayer
{
    if (nil != invitedPlayer.userObject)
    {
        [self.gameObject setObject:invitedPlayer.userObject forKey:GAME_INVITED_PLAYER];
    }
}

-(User*)invitedPlayer
{
    NSObject *value = [self.gameObject objectForKey:GAME_INVITED_PLAYER];
    if ([value isKindOfClass:[PFUser class]])
    {
        return [User userFromPFUser:(PFUser*)value];
    }

    return nil;
}
  • 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-01T10:26:13+00:00Added an answer on June 1, 2026 at 10:26 am

    What would be a good way to insure that the properties of my object are not released prematurely.

    Holding onto them by maintaining a strong reference. It is extremely unlikely that ARC is randomly releasing your data. Much more likely is that you are letting go of it when you don’t mean to.

    The first place I’d look is at your use of setCurrentGame:, making sure that you’re not accidentally working on different Game objects at the same time in different parts of the program. First, make sure t

    Your +get... methods are awkwardly named (a get prefix means a very specific thing in ObjC, and it’s not what you’re doing here). Havings class methods that take targets and actions like this seems a likely place to have trouble. It makes me wonder what’s going on inside there.

    Your conversion between two kinds of User objects is a little suspicious, and I’d make sure you’re not accidentally dropping User or PFUser objects when you don’t mean to.

    Generally speaking, though, this question is over-vague. Are you winding up with dangling strong pointers? Are your strong pointers seeming to become nil? Is your game object itself becoming nil? How do you know when things are being “released?” Or do you mean that they’re deallocating? Have you put a breakpoint in dealloc to see who had the last reference to the object?

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

Sidebar

Related Questions

I have a web application, which has Servlet and a static Class accessed through
I need to mock a GrailsControllerClass interface. Instance should have a static variable defined.
Suppose I have static ip in a subnet that has DHCP server. If i
I have an Excel plug-in (written in C#) with a static variable that is
I have a static method in my code that I would like somehow to
I have some static resources (images and HTML files) that will be localized. One
Where have you mostly used the initialization block? Can you use these to assign
I have the following code with private static members. All of these classes say
We know that a single application instance can use multiple cores and even multiple
I have a a wait form FormWait (long running task notification), that has ShowMessage(string

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.