Best way to save a simple text file?
Best way to save a simple text file?
- Subject: Best way to save a simple text file?
- From: Jean-Nicolas Jolivet <email@hidden>
- Date: Fri, 16 Nov 2007 13:02:01 -0500
What would be the best way to save a simple NSString to a text file in a
document based application?
Right now I am using the following (in writeToUrl:ofType:error method):
---------------------------------------------
NSData *data = [NSData dataWithBytes: [myString UTF8String]
length:[myString length]];
BOOL writeSuccess = [data writeToURL:inAbsoluteURL atomically:NO];
---------------------------------------------
However, I was wondering... is it really necessary for me to convert my
string to an NSData object before saving it? Isn't there any other way
to do it? Also, what if I would like to support multiple languages (i.e.
multiple encoding??)... right now the string is converted to UTF8...
So.. in other words...any other technique to save a simple NSString to a
text file? (Same goes for opening... do I need to convert to NSData??
Assuming I want to do file opening in readFromUrl). There are many
different examples, but they all do it a different way (and most are
outdated...i.e. using deprecated methods)...
Thanks
_______________________________________________
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