> On Tue, 2009/05/26, Volker in Lists <volker_li...@ecoobs.de> wrote: > From: Volker in Lists <volker_li...@ecoobs.de> > Subject: Re: what am I missing with NSString ? > To: "vinai" <for_use...@yahoo.com> > Cc: Cocoa-dev@lists.apple.com > Date: Tuesday, 2009 May 26, 08:41 > from the code listed I cannot tell if you alloc'ed memory > for your NSString at all? > > What is the goal you try to achieve? If you just want to > store a single file path... with a global NSString do as > along the lines of: > > [rawFileName release]; > rawFileName = [[NSString alloc] initWithString:[[files > objectAtIndex:i] stringByStandardizingPath]]];
The NSString reference suggests that it will return an object. Since it's an instance method and not a class method, this suggests that an alloced string must be the receiver. "Returns an NSString object initialized by copying the characters from another given string. - (id)initWithString:(NSString *)aString " OTOH, stringWithString is a class method, suggesting that it must be sent to NSString and it will take care of the alloc: "Returns a string created by copying the characters from another given string. + (id)stringWithString:(NSString *)aString " _______________________________________________ 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