Changes

Jump to: navigation, search

IPhone Data Persistence using Archiving

556 bytes removed, 12:34, 30 July 2010
Checking for the Existence of the Archive File on Startup
Having identified the path to the archive data file, the file manager object is used to check for the existence of the file. If it exists, the file is “unarchived” into a new array object using the unarchiveObjectWithFile method of the NSKeyedUnarchiver class. The data is then extracted from the array and displayed in the corresponding text fields.
 
Before implementing the action method, we need to take care of some memory issues and make sure we free up any memory we have allocated. In the viewDidLoad method we release the file manager object we created. We also need to modify a few other methods to free up the memory used to hold the data file pathname:
 
<pre>
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.dataFilePath = nil;
}
 
- (void)dealloc {
[dataFilePath release];
[super dealloc];
}
</pre>
With this code implemented, select the ''Build and Run'' toolbar button to compile and execute the application in the simulator. Assuming no problems are encountered, the next step is to implement the action method. If problems are encountered, check the details reported by Xcode and correct any syntax errors that may have been introduced into the code.

Navigation menu