what am I missing with NSString ?

2009-05-26 Thread vinai
Hi Folks, I think I am missing something really basic here with NSString. I am trying to store the path of a user-selected file (from an NSOpenPanel) internally so other routines can act on the data within the file. Here's the relevant section of code: if ([oPanel

Re: what am I missing with NSString ?

2009-05-26 Thread Michael Vannorsdel
rawFileName = [[NSString alloc] initWithString:[[files objectAtIndex:i] stringByStandardizingPath]]; Be sure to release rawFileName before you replace it with a new path. On May 26, 2009, at 7:33 AM, vinai wrote: think I am missing something really basic here with NSString. I am trying

Re: what am I missing with NSString ?

2009-05-26 Thread Volker in Lists
Hi, 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]

Re: what am I missing with NSString ?

2009-05-26 Thread Ken Thomases
On May 26, 2009, at 8:33 AM, vinai wrote: I think I am missing something really basic here with NSString. Actually, it seems you're missing stuff much more basic than that. You seem to not understand the difference between a pointer and an object (which a pointer might point to).

Re: what am I missing with NSString ?

2009-05-26 Thread vinai
Hi All, Thanks so much to Micheal, Volker, and esp. to Ken for the pointer/object refresher. I think my mistake came from thinking that NSString's initWithString method did memory allocation as well, and would create a new object in one swell foop. ;-) From my own trials and failures, and

Re: what am I missing with NSString ?

2009-05-26 Thread Jeffrey Oleander
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