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];

时间: 2024-09-29 18:28:21

IOS Intro - Write file的相关文章

【ZBar】ios错误ignoring file xxx missing required architecture x86_64 in file

解决方法: 1.在Project target里"Architectures"设置为:Standard (armv7,armv7s)或者  Standard (armv7,arm64) 2.设置"Build Active Architecture Only"为"NO" 还有一篇文章说的很牛逼,但是还咩有看,http://blog.csdn.net/lanmanck/article/details/39055503 原文地址:[ZBar]ios错误

IOS Intro - Property Synthesis

http://www.thecodecrate.com/ios/objective-c/objective-c-property-synthesize/ 01. atomic                   // default02. nonatomic03. strong=retain            // default04. weak= unsafe_unretained05. retain06. assign                   // default07. un

iOS 链接错误file was built for archive which is not the architecture being linked (i386)

iOS 环境下,链接某个静态库(.a文件)时,Xcode 会出现链接错误: xxx file was built for archive which is not the architecture being linked (i386) 这是因为静态库是为iOS 环境编译的,并不能在模拟器环境下使用,只要将Build 目标改成设备即可.如果是: ld: warning: ignoring file ./libsasl2.a, file was built for archive which is

iOS之input file调用相册控制器消失跳转到登陆页

最近在做一个app要用到H5,其中有一个需求是要点击H5的的控件弹出系统相册,通过在H5的input file 中定义<input type="file" class="ios_only" accept="image/*" capture="camera">调用系统相册时虽然可以弹出如下的alertView 但是当点击相册时却相册,反而是跳转到登陆面,查看控制台发现发现报了如下的错误: 根据字面意思理解为我的四个控

iOS - 文件操作(File Operating)

1. 沙盒 & NSData /*_______________________________获取沙盒路径_________________________________________*/ //第一种获取方式 //NSHomeDirectory();获取到沙盒的目录路径 NSString *homePath = NSHomeDirectory(); NSLog(@"沙盒目录:%@",homePath); NSString *docPath1 = [NSString str

ios错误ignoring file xxx missing required architecture x86_64 in file

解决方法: 1.在Project target里"Architectures"设置为:Standard (armv7,armv7s)或者  Standard (armv7,arm64) 2.设置"Build Active Architecture Only"为"NO" 3.在Project target里"Build Settings"的"Valid Architectures"添加"i386&q

IOS Intro - NSDictionary and NSMutableDictionary

NSDictionary.NSMutableDictionary的基本用法 1.不可变词典NSDictionary 字典初始化 NSNumber *numObj = [NSNumber numberWithInt:100]; 以一个元素初始化 NSDictionary *dic = [NSDictionary dictionaryWithObject:numObj forKey:@"key"]; 初始化两个元素 NSDictionary *dic = [NSDictionary dic

Differences Between Xcode Project Templates for iOS Apps

Differences Between Xcode Project Templates for iOS Apps When you create a new iOS app project in Xcode, you get to choose between several project templates, from the aptly named “Empty Application” to specialized things like an “OpenGL Game”. I noti

iOS 9 App Search教程

原文链接 : iOS 9 App Search Tutorial: Introduction to App Search 原文作者 : Chris Wagner 译文出自 : 开发技术前线 www.devtf.cn 译者 : kmyhy Ray 注:本文作为<iOS 9 Feast>中的一部分,节略自 <iOS 9 Tutorials>其中一章--通过本文,您可对全书内容窥见一斑.祝您阅读愉快! 在相当长的一段时间内,iOS 的 Spotlight 都是一个大坑.尽管用户可以用它来