IOS Intro - Write file
Posted fanbird2008
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IOS Intro - Write file相关的知识,希望对你有一定的参考价值。
#import <sys/xattr.h>
+ (NSString *)getFullFilePathInDocuments:(NSString *)subFilePath fileName:(NSString *)fileName
{
NSString *filePath = [NSString stringWithFormat:@"%@/Documents%@", NSHomeDirectory(), subFilePath];
// NSLog(@"function:%s,getFilePath %@", __FUNCTION__,filePath);
NSFileManager* fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:filePath]) {
return [NSString stringWithFormat:@"%@/%@", filePath, fileName];
}
if ([fm createDirectoryAtPath:filePath
withIntermediateDirectories:YES
attributes:nil
error:nil])
{
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
return [NSString stringWithFormat:@"%@/%@", filePath, fileName];
}
return nil;
}
self.mFile = [MagicEntity getFullFilePathInDocuments:@"/test" fileName:@"yuv.bin"];
NSData *data = [[NSData alloc] initWithBytes:I420 length:w * h * 3 / 2];
bool r = [data writeToFile:self.mFile atomically:true];
以上是关于IOS Intro - Write file的主要内容,如果未能解决你的问题,请参考以下文章
IOS Intro - NSDictionary and NSMutableDictionary