Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Lakario

macrumors member
Original poster
Oct 29, 2008
30
0
In one of my application classes (subclass of TableCell) I create some static fields that are initialized for the whole class.

Code:
static UIImage *checkedImage = nil;

@implementation ItemCell

+(void)initialize {
	checkedImage = [[UIImage imageNamed:@"checkbox_checked.png"] retain];
}

As far as memory management is concerned, where should these items be released? Is there a static dealloc?
 

SqueegyX

macrumors regular
Mar 24, 2008
108
1
I don't think you really need to release those. When the app quits, any memory allocated to is immediately reclaimed. So for objects that need to exist for the entire life of your running application, I wouldn't worry about it.

Although, I would happy to know of a cleaner way from someone smarter than I.
 

Lakario

macrumors member
Original poster
Oct 29, 2008
30
0
I don't think you really need to release those. When the app quits, any memory allocated to is immediately reclaimed. So for objects that need to exist for the entire life of your running application, I wouldn't worry about it.

Although, I would happy to know of a cleaner way from someone smarter than I.

This thread seems to essentially reiterate what you said. Thanks for the input. :)
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
In general you don't release these kinds of objects.

However, you could treat it as a singleton. In that case it would be loaded lazily, not inside +initialize. And you could release it and nil the variable if you got a memory warning. It would be reloaded if it was needed after that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.