Re: NSMyBrainJustMelted - newbie - cocoa/java - desktop folder
Re: NSMyBrainJustMelted - newbie - cocoa/java - desktop folder
- Subject: Re: NSMyBrainJustMelted - newbie - cocoa/java - desktop folder
- From: Volker Runkel <email@hidden>
- Date: Tue, 14 Jun 2005 10:21:26 +0200
Hi Jeff,
there is a constructor for NSSring / NSMutableString that allows to
load the file contents into a string object easily:
NSString *myString = [NSString stringWithContentsOfFile:@"theFilePath"];
If you want to use "~/desktop/foo.txt" you have to expand the path
first to the whole path, the ~ is not valid for file paths!
An example:
NSString *myString = [NSString stringWithContentsOfFile:[@"~/desktop/
foo.txt" stringByExpandingTildeInPath]];
This leads to a String object with the contents of the fiel loaded.
I recommend reading
file:///Developer/ADC Reference Library/documentation/Cocoa/
Conceptual/Strings/index.html#//apple_ref/doc/uid/10000035i
for more information on how to deal with strings.
Volker
- - - - - - - - - - - - - ------ ---- ---- --- -- - - - - -
- - - - - - - - - -
Dipl.-Biol. Volker Runkel
Lehrstuhl f. Zoologie II www.biologie.uni-
erlangen.de/zoo2
Staudtstr. 5 Telefon:
09131-85 28788
91058 Erlangen email@hidden-
erlangen.de
- - - - - - - - - - - - - ------ ---- ---- --- -- - - - - -
- - - - - - - - - -
Am 14.06.2005 um 09:25 schrieb Jeff Pritchard:
Hi,
I'm a geriatric Codewarrior MacOS <X programmer trying to start
fresh with Tiger/cocoa/java/xcode.
Something as simple as reading in the contents of a text file from
the desktop has just brought me to my knees.
Seems like I probably need to use NSFileWrapper and NSPathUtilities
in some clever way, but for the life of me I can't figure it out
from the overly terse documentation. How should I go about
getting "~/desktop/foo.txt" loaded into a String object?
Apparently my simple path string does not satisfy the string
constructor of NSFileWrapper.
many thanks,
jp
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden