NSString and retain.
NSString and retain.
- Subject: NSString and retain.
- From: jon <email@hidden>
- Date: Mon, 11 May 2009 20:15:26 -0600
from my very limited Objective-C programing experience of all of 10
days...
it appears to me that my assignments to NSStrings seem to, at random,
disappear..... (i, being a new Objective-C programmer coming from
pascal and C, like to have a "global" string in several places, not
that it is correct or anything, but i still would like to know what is
going on when i do keep a string around for a good long time in the
application) (or any other object for that matter)
I attribute it so far to my lack of understanding garbage collection
and retaining objects...
my wild guess right now is to do this below when ever i have the
"NSString" instance assignment to prevent, for instance, "theTitle"
from "randomly disappearing"...
ok, tell me how badly this will go wrong... (although this would be
more like "theTitle" is declared in an area that is global, and then
assigned later.)
I do know that "NSSTring" is "different" than other objects, but i'm
not sure how, they do appear to act like other objects though as far
as i can tell.
thanks in advance,
Jon.
NSString *theTitle = [[defaults stringForKey:@"the title"] retain];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden