Saving and Loading the Checklist Items
2013-03-08 06:15
375 查看
Saving
- (NSString *)documentsDirectory
{
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
//asd
NSString *documentsDirectory = [paths
objectAtIndex:0];
return documentsDirectory;
}
- (NSString *)dataFilePath
{
return [[self
documentsDirectory] stringByAppendingPathComponent:@"Checklists.plist"];
//Create new string asd/Checklists.plist
}
- (void)viewDidLoad
{
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Documents folder is %@",[self
documentsDirectory]);
NSLog(@"Data file path is %@", [self
dataFilePath]);
...
}
pp154
Loading
pp164
- (void)loadChecklistsItems
{
NSString *path = [self
dataFilePath];
if ([[NSFileManager
defaultManager] fileExistsAtPath:path]) {
NSData *data = [[NSData
alloc] initWithContentsOfFile:path];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver
alloc] initForReadingWithData:data];
items = [unarchiver
decodeObjectForKey:@"ChelistItems"];
} else {
items = [[NSMutableArray
alloc] initWithCapacity:20];
}
}
//restore For viewcontrollers that are automatically loaded from a nib or storyboard
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super
initWithCoder:aDecoder]) {
[self
loadChecklistsItems];
}
return self;
}
- (NSString *)documentsDirectory
{
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
//asd
NSString *documentsDirectory = [paths
objectAtIndex:0];
return documentsDirectory;
}
- (NSString *)dataFilePath
{
return [[self
documentsDirectory] stringByAppendingPathComponent:@"Checklists.plist"];
//Create new string asd/Checklists.plist
}
- (void)viewDidLoad
{
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Documents folder is %@",[self
documentsDirectory]);
NSLog(@"Data file path is %@", [self
dataFilePath]);
...
}
pp154
Loading
pp164
- (void)loadChecklistsItems
{
NSString *path = [self
dataFilePath];
if ([[NSFileManager
defaultManager] fileExistsAtPath:path]) {
NSData *data = [[NSData
alloc] initWithContentsOfFile:path];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver
alloc] initForReadingWithData:data];
items = [unarchiver
decodeObjectForKey:@"ChelistItems"];
} else {
items = [[NSMutableArray
alloc] initWithCapacity:20];
}
}
//restore For viewcontrollers that are automatically loaded from a nib or storyboard
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super
initWithCoder:aDecoder]) {
[self
loadChecklistsItems];
}
return self;
}
相关文章推荐
- Break the list items Inheritance permission and custom the permission with ItemAdded Event
- Saving and Loading the State of Multitasking Apps(多任务应用中,状态变化的处理)
- Adding new items to the Checklist
- Noticed a strange thing the other day, a list has the property ItemCount and also an Items collection which has its own .Count b
- The list of vision-based SLAM / Visual Odometry open source projects, libraries, dataset, tools, and
- Connection to localhost:5432 refused. Check that the hostname and port are correct and that the post
- Ethereum Smart Contract Safety and Security Checklist
- [BTS] Loading property information list by namespace failed or property not found in the list. Verify that the schema is deployed properly.
- [Immutable.js] Differences between the Immutable.js Map() and List()
- List of X$ Tables and how the names are derived
- Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment vari
- The Agile Checklist
- Android: Loading files from the Assets and Raw folders
- An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON
- [转]The Big List of JavaScript, CSS, and HTML Development Tools, Libraries, Projects, and Books
- What happen and What should I do to check with the VIP
- System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list
- how to check port number and kill process with the port number
- Please check the configured value for ha.zookeeper.quorum and ensure that ZooKeeper is running.
- Factors to Consider and checklist When Selecting Project Team Members