NSData

NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentPath = [pathArray firstObject];

NSString *filePath = [documentPath stringByAppendingPathComponent:@"test.txt"];

// 写入文件

NSString *testStr = @"test....hello world!";

[testStr writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];

// 读取文件

NSData *data = [NSData dataWithContentsOfFile:filePath];

NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

NSLog(@"DATASTR = %@", dataStr);

上一篇:基于.NET的CAD二次开发学习笔记一:CAD开发入门


下一篇:A Tour of Go For continued