On Sat, Jun 14, 2008 at 11:35 PM, Christopher J Kemsley <[EMAIL PROTECTED]> wrote: > That being said, if I do the following: > > > NSString *someString = [ NSString stringWithString:@"Hello World!" ] ; > [ someNSTextField setStringValue:someString ] ; > > > Does the NSTextField take care of de-allocating the memory from the old > value by itself?
When learning Cocoa, read, re-read, and frequently reference the Cocoa memory management guide. It explains what's going on here: 1) You get an object from a method other than +alloc. This means you're responsible for sending this object -retain, or else it might go away later. 2) You hand this object off to an NSTextField. Same thing applies: the NSTextField is responsible for sending the string -retain, or else it might disappear. 3) You didn't send the string -retain, so you must not call -release or -autorelease. This is where your concern about the object's memory ends. Now, as far as the text field is concerned, it can do whatever it wants: -retain the string (and then be responsible for releasing it later) or copy it or other things. None of your concern as long as you hold up your end of the memory management bargain. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]