Need to release "constant objects"?
Need to release "constant objects"?
- Subject: Need to release "constant objects"?
- From: Jerry Krinock <email@hidden>
- Date: Tue, 04 May 2004 16:48:54 -0700
I use these things I call "constant objects", mostly strings, that I assign
to other variables, as needed, in a particular class. So, I declare them as
globals at the top of the file like this (I show NSNumbers instead of
NSStrings as examples because the shorter lines fit better in email):
static NSNumber* objectTrue;
static NSNumber* objectFalse;
then I create them in my class's -init method:
objectTrue = [[NSNumber alloc] initWithBool:TRUE] ;
objectFalse = [[NSNumber alloc] initWithBool:FALSE] ;
and then I just assign to other variables whenever needed.
I never bother to release them, because I need them as long as the program
is running. I was wondering, however, when I run "leaks" from the command
line, do these show up as leaks and, if so, is there a better idiom? I like
to see no warnings and no leaks.
Jerry Krinock
San Jose CA USA
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.