• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: what am I missing with NSString ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what am I missing with NSString ?


  • Subject: Re: what am I missing with NSString ?
  • From: Michael Vannorsdel <email@hidden>
  • Date: Tue, 26 May 2009 07:40:00 -0600

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@hidden)

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:
This email sent to email@hidden


References: 
 >what am I missing with NSString ? (From: vinai <email@hidden>)

  • Prev by Date: Re: Displaying a number with Quartz
  • Next by Date: Re: what am I missing with NSString ?
  • Previous by thread: what am I missing with NSString ?
  • Next by thread: Re: what am I missing with NSString ?
  • Index(es):
    • Date
    • Thread