Thanks.. perfect explanation. On Feb 3, 2010, at 12:37 PM, Jens Alfke wrote:
> > On Feb 3, 2010, at 3:55 AM, Philip Vallone wrote: > >> currentSection = @"Some value"; >> The retain count goes to 1 > > This assigns a new value to the pointer variable 'currentSection'. It now > points to the immutable string literal @"Some value". > >> However if I assign a value with >> [currentSection setString:@"Some value"]; >> The retain count is still zero. > > This tells the mutable string object that 'currentSection' currently points > to, to replace its contents with the characters in the string @"Some value". > > If you find the retain count is zero after this, it's probably because the > value of 'currentSection' is nil, i.e. it doesn't point to any object. In > that case the -setString: message is a no-op since messages to nil are > ignored, and -retainCount will return zero because messages to nil always > return 0/nil. > > In general, it sounds as though you're unclear on the distinction between an > object and a pointer to an object. It's the same as structs vs. pointers to > structs in C, or for objects in C++; the difference is that Objective-C > objects can only be referred to by pointers (you can't have a variable of > type "NSString", only "NSString*".) > > —Jens _______________________________________________ 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 arch...@mail-archive.com