NS Data //********** STORE NSDATA ********** NSString *FilePath = [NSHomeDirectory() stringByAppendingPathComponent:@”Library/Caches/users.xml”]; [FileData writeToFile:FilePath atomically:YES]; //Write it overwriting any previous file (atomically writes to a temporary location before copying to permanent – good protection in case app should crash) //********** GET NSDATA ********** NSString *FilePath; NSData *FileData; NSString *FilePath = [NSHomeDirectory() stringByAppendingPathComponent:@”Library/Caches/users.xml”]; FileData = [NSData dataWithContentsOfFile:FilePath]; […]
Category: File Saving and Loading
Using Archiving
When a class conforms to the NSCoding protocol it can be archived and later loaded into the application. Archiving is very simple to use. To make a class suitable for archiving you simply need to use the NSCoding delegate and implement the encodeWithEncoder and initWithEncoder funcitons. The class is then ready to be stored and […]