[size=medium]
SQLine Demo:[url]http://www.wuleilei.com/blog/264[/url][/size]
NSKeyedUnarchiver[url]http://285746555.blog.51cto.com/2966432/647312[/url]
NSValue、CGPoint 序列化的问题等
[list][*]文件、属性列表
[*]对象归档
[*]SQLite
[*]Core Data
[/list]
[size=large]
NSUserDefaults
NSFileHandle
NSFileManager
NSUserDefaults
[/size]
NSString * msg = [NSString stringWithFormat:@"%d : %@\n", i, [NSDate date]];
NSString * path = 。。。;
NSFileHandle *fh = [NSFileHandle fileHandleForWritingAtPath:path];
[fh seekToEndOfFile];
[fh writeData:[msg dataUsingEncoding:NSUTF8StringEncoding]];
[fh closeFile];
[NSFileManager defaultManager]//单例
[[NSFileManager alloc]init] // 线程安全
[size=medium]
// NSFileManager的方法介绍
[url]http://apps.hi.baidu.com/share/detail/38263560[/url]
// 遍历文件、目录
[url]http://kevin-wu.net/tips-for-using-nsfilemanager-to-get-filefolder-list/[/url]
// 文件排序
[url]http://www.acwind.net/blog/?p=1116[/url][/size]
[size=large]NSUserDefaults
[url]http://www.cnblogs.com/zengwu/archive/2011/02/25/1964908.html[/url][/size]
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"111" forKey:@"myTest"];
[defaults synchronize];//写入disk
NSString *testStr = [defaults objectForKey:@"myTest"];//再次读出
NSLog(@"testStr is: %@",testStr);
NSString * path = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"json"];
[size=x-large]第8章枚举目录[/size]
#import
int main (int argc, const char * argv[])
{
// 可变的Array
NSMutableArray *files = [NSMutableArray arrayWithCapacity:0];
// 目录管理对象
NSFileManager *manager = [NSFileManager defaultManager];
// ~ 用户主目录
NSString *homeDir = [@"~" stringByExpandingTildeInPath];
NSDirectoryEnumerator *dirEnum = [manager enumeratorAtPath:homeDir];
// 枚举文件
for (NSString *fileName; fileName = [dirEnum nextObject];)
{
if ([[fileName pathExtension] isEqualTo:@"jpg"])
{
[files addObject:fileName];
}
}
// 快速枚举
for (NSString *fileName in files)
NSLog(@"%@", fileName);
/*
//普通枚举
NSEnumerator *fileEnum = [files objectEnumerator];
while (fileName = [fileEnum nextObject]) {
NSLog(@"%@", fileName);
}
*/
return 0;
}
[size=x-large]第三章读文件[/size]
#import
int main (int argc, const char * argv[])
{
NSLog(@"file path = %s",argv[1]);
FILE *file = fopen(argv[1], "r");
char buf[128] = {0};
while (fgets(buf, 128, file))
{
buf[strlen(buf) - 1] = '\0';
NSLog(@"length = %d,content = %s",strlen(buf), buf);
}
return 0;
}