Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

liptonlover

macrumors 6502a
Original poster
Mar 13, 2008
989
0
Didn't expect to be posting again so soon, but here I am.

I'm trying to save and load from a text file. I set up a text file in my documents folder and can save to it,

#import "save.h"

@implementation save
NSString *path=@"/Users/nate/Documents/test.txt";
NSString *data;
- (IBAction)load:(id)sender {

}

- (IBAction)save:(id)sender {
data=[field stringValue];
[data writeToFile:path atomically:NO];
}
@end

(The text is definitely saving; I checked with textedit)

but I can't find any way to load. I'm looking under NSData but there is no readFromFile:Atomically: or anything like that.
 

Cromulent

macrumors 604
Oct 2, 2006
6,816
1,100
The Land of Hope and Glory
This page explains it all.

http://developer.apple.com/document...ileWrappers.html#//apple_ref/doc/uid/20000775

Specifically:

Besides saving its contents to disk, a file wrapper can re-read them from disk when necessary. The needsToBeUpdatedFromPath: method determines whether a disk representation may have changed, based on the file attributes stored the last time the file was read or written. If the file wrapper’s modification time or access permissions are different from those of the file on disk, this method returns YES. You can then use updateFromPath: to re-read the file from disk.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.