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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:22:03+00:00 2026-06-05T13:22:03+00:00

I have a -dealloc() method which I am assuming I can use to dealloc

  • 0

I have a -dealloc() method which I am assuming I can use to dealloc instance variables, I have another variable that is not in the instance, rather a class level variable, wondering when & how I dealloc this? I can’t do it in the instance method dealloc() right? Code below for reference (on varaible: levelHash):

@interface Level : CCNode 
    { 
        //Instance variables
        PlayBackgroundLayer* playBGLayer;
        PlayTilemapLayer* playTilemapLayer;
        PlayUILayer* playUILayer;
        PlayElementLayer* playElementLayer;
    }
    //Property declarations for instance variables
    @property (nonatomic, retain) PlayBackgroundLayer* playBGLayer;
    @property (nonatomic, retain) PlayTilemapLayer* playTilemapLayer;
    @property (nonatomic, retain) PlayUILayer* playUILayer;
    @property (nonatomic, retain) PlayElementLayer* playElementLayer;

    //Static methods
    +(void) Initialize: (NSString*) levelReference;
    +(void) InitLevel: (NSString*) levelReference;
    +(Level*) GetCurrentLevel;
@end

//static variables
NSMutableDictionary *levelHash;

and my implementation:

+(void) Initialize: (NSString*) levelReference 
{
    levelHash = [[NSMutableDictionary alloc] init];
    [levelHash setObject:NSStringFromClass([LevelOne class]) forKey:@"1"];
    //EG CALL IT [levelHash objectForKey:@"foo"];
    //WHEN DO I CALL THIS??? [levelHash release];
}
  • 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-05T13:22:04+00:00Added an answer on June 5, 2026 at 1:22 pm

    Classes aren’t deallocated for the life of your program, so there doesn’t seem to be much point in releasing that dictionary. All the memory your app uses is reclaimed when it terminates. You can create a “tear down” method for the class where you release the dictionary if you want to, just as you’ve created a custom initialization method.

    (By the way, it is neither a class nor a static variable; ObjC doesn’t have class variables and, lacking the static keyword, it’s actually global. This is why there’s no need to worry about a leak — global variables also exist for the entire lifetime of your program.

    Also, you shouldn’t be putting it in your header file, as I mentioned earlier. Every file that imports this header is going to be re-defining it, which will cause a linker error — you can only define things once.)

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

Sidebar

Related Questions

Consider I have a property named sampleObject. In dealloc method, which should be the
Do I have to call release in the dealloc method of a class for
I have an instance of a UITableView, and a separate class that adheres to
I have a controller that makes HTTP GET requests using a custom class, which
I have an objective-C++ class which contain some honest C++ object pointers. When the
I have a very classical class which contains buttons and label, etc... : @interface
I have a very simple class called Profile. It contains NSMutableArray called avatar which
I have a UITableViewController which has a UIView* called errorView that is used to
I have this simple class which I know is ok in terms of memory
UIWebViewDelegate Protocol Reference states that: Before releasing an instance of UIWebView for which you

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.