










NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths firstObject];
NSFileManager *fileManager = [NSFileManager defaultManager];
//创建文件夹
NSString *dataPath = [cachePath stringByAppendingPathComponent:@"FirstData"];
NSError *createError;
[fileManager createDirectoryAtPath:dataPath withIntermediateDirectories:YES attributes:nil error:&createError];
//创建文件
NSString *listDataPath = [dataPath stringByAppendingPathComponent:@"list"];
NSData *listData = [@"abc" dataUsingEncoding:NSUTF8StringEncoding];
[fileManager createFileAtPath:listDataPath contents:listData attributes:nil];
//查询文件
BOOL fileExist = [fileManager fileExistsAtPath:listDataPath];
if (fileExist) {
//文件追加内容
NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:listDataPath];
[fileHandle seekToEndOfFile];
[fileHandle writeData:[@"\ndef" dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandle synchronizeFile];
[fileHandle closeFile];
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。