2012年3月27日
摘要: 让Model类遵循NSCoding 和 NSCopying 协议并实现三个方法:- (void)encodeWithCoder:(NSCoder *)encoder {/*[super encodeWithCoder:encoder];//If you are subclassing a class that also conforms to NSCoding, you need to make sure you call encodeWithCoder: on your superclass,*/[encoder encodeObject:foo forKey:kFooKey];[encod 阅读全文
posted @ 2012-03-27 09:57 老Zhan 阅读(469) 评论(0) 推荐(0) 编辑
摘要: 定义两个方法:- (NSString *)dataFilePath;获取返回数据文件的完整路径名- (void)applicationWillResignActive:(NSNotification *)notification;保存数据,参数notification的作用是在对象之间传递通知,保持通信。#define kFilename @"data.plist"- (NSString *)dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains( ... 阅读全文
posted @ 2012-03-27 09:26 老Zhan 阅读(335) 评论(0) 推荐(0) 编辑
摘要: iphone上的数据存储有四种模式:Property lists 属性列表 Object archives (or archiving) 对象归档 SQLite3 (iOS’s embedded relational database) Core Data (Apple’s provided persistence tool)存储中经常需要提取两个相关的目录路径:Documents和tmpGetting the Documents Directory :NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentD... 阅读全文
posted @ 2012-03-27 09:14 老Zhan 阅读(349) 评论(0) 推荐(0) 编辑