• 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: Volker in Lists <email@hidden>
  • Date: Tue, 26 May 2009 15:41:21 +0200

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] initWithString:[[files objectAtIndex:i] stringByStandardizingPath]]];


Of course that will give you the last of the selected files stored in the rawFileName string object. Alternatively you can use a mutable string and replace the contents with the selected filename.

Maybe that helps to point you in the right directions ...

Volker


Am 26.05.2009 um 15:33 schrieb 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 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.

vinai




_______________________________________________

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

_______________________________________________

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: what am I missing with NSString ?
  • Next by Date: [OT] default boot device
  • Previous by thread: Re: what am I missing with NSString ?
  • Next by thread: Re: what am I missing with NSString ?
  • Index(es):
    • Date
    • Thread