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 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 runModalForDirectory:nil file:nil types:nil] == NSOKButton)
   {
       NSArray * files = [oPanel filenames];

       /* Process files */

       for( i = 0; i < [files count]; i++ )
       {
[rawFileName initWithString: [[files objectAtIndex:i] stringByStandardizingPath]];
           NSLog(@"Logging the file name variable");
           NSLog(rawFileName);

           NSLog(@"Logging the called file path object directly");
           NSLog([[files objectAtIndex:i] stringByStandardizingPath]);
       }
   }

and this is the output from that section of code:

2009-05-26 09:18:41.931 REMI[19710:807] Logging the file name variable
2009-05-26 09:18:41.932 REMI[19710:807] Logging the called file path object directly 2009-05-26 09:18:41.932 REMI[19710:807] /Users/vinai/Desktop/ rawTestData/P04608.7

rawFileName is declared to be an NSString * in my object's header file. So why does printing out the string returned by the stringByStandardizingPath function work okay, but not when initializing an NSString * variable with it ? What would I need to rawFileName so it can be used by other methods in my object ?

Thanks much all.

_______________________________________________

Cocoa-dev mailing list ([email protected])

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]

Reply via email to