• 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: Irritating Problem with NSString Method and File Paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Irritating Problem with NSString Method and File Paths


  • Subject: Re: Irritating Problem with NSString Method and File Paths
  • From: Jack Carbaugh <email@hidden>
  • Date: Mon, 4 Aug 2008 00:54:40 -0400

when i refer to a file, i used:

file = [[NSMutableDictionary alloc] initWithContentsOfFile:[Folder stringByAppendingPathComponent: FileName]];

Folder is set up as:
Folder = [[NSString alloc] initWithString:[@"path" stringByExpandingTildeInPath]];


and Filename is:
FileName    = [[NSMutableString alloc] initWithString:@"filename.txt"];


perhaps that may help.

jack


On Aug 4, 2008, at Mon-08 /04 /08-12:43 AM, Patrick Walker wrote:

It seems that whenever I use Xcode to spawn the program, it is able to find the file but when spawning the program from Finder, it can never, ever find the file. I've been looking online and no one seems to have come across this before or maybe it's because it's so late that I'm not seeing the obvious.

NSString *fileContents = [[NSString alloc] initWithContentsOfFile: [filename stringValue]
encoding:NSASCIIStringEncoding
error:nil];
Filename is an NSTextField outlet, btw.


We've tried all sorts of things to try and find the file, File.txt, ./File.txt, ~/File.txt, "./File.txt". I can understand maybe the ~ doesn't work for all shells but explicitly using
./File.txt should be opening the file in the current directory with the executable, shouldn't it? Do I *really* have to append a huge long path each time I want to open a file?


Any ideas? It says path and the documentation says that it has to be NSString. I've used filepaths before for open() but those are C strings and those are full paths though, i.e., /dev/stdout. It's such a simple problem what am I missing here?
_______________________________________________


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: 
 >Irritating Problem with NSString Method and File Paths (From: Patrick Walker <email@hidden>)

  • Prev by Date: Re: Documentation
  • Next by Date: Re: NSSplitView Question
  • Previous by thread: Re: Irritating Problem with NSString Method and File Paths
  • Next by thread: Re: Irritating Problem with NSString Method and File Paths
  • Index(es):
    • Date
    • Thread