• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSString and retain.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSString and retain.
      • From: Andy Lee <email@hidden>
    • Re: NSString and retain.
      • From: Clark Cox <email@hidden>
References: 
 >quick and dirty NSData implosion (From: Jon <email@hidden>)
 >Re: quick and dirty NSData implosion (From: Alexander Spohr <email@hidden>)
 >Re: quick and dirty NSData implosion (From: jon <email@hidden>)
 >Re: quick and dirty NSData implosion (From: John Cebasek <email@hidden>)
 >Re: quick and dirty NSData implosion (From: jon <email@hidden>)
 >Re: quick and dirty NSData implosion (From: Graham Cox <email@hidden>)
 >Re: quick and dirty NSData implosion (From: jon <email@hidden>)
 >Re: quick and dirty NSData implosion (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: quick and dirty NSData implosion
  • Next by Date: Re: custom NSViews and subviews - creating in IB
  • Previous by thread: Debugger's "global browser" does not show any globals?
  • Next by thread: Re: NSString and retain.
  • Index(es):
    • Date
    • Thread