-
iOS读取本地文件
需先将要读取的文件,加载到工程Bundle Resource。(不可直接从Mac上读取文件,呜呜。。。)
代码中通过 [[NSBundle mainBundle] resourcePath] 获取文件路径。
//文件名
NSString* av1StreamName = @"v1_av1_2F.ivf";
//最终文件路径
NSString* streamPath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], av1StreamName];
-
iOS写文件
写文件地址,写到当前app Documents文件夹
//输出文件路径
NSArray* arrDownloadPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString* loadPathsPath = [arrDownloadPaths objectAtIndex:0];
//输出文件名
NSString* outYUVName = @"decode.yuv";
NSString* outYUVPath = [NSString stringWithFormat:@"%@/%@", loadPathsPath, outYUVName];
Mac上查看iOS上生成的文件,在Xcode上方菜单栏Window -->Device 中,右键设置选项,选择 Download Container 下载沙盒文件到Mac上。参考https://www.jianshu.com/p/0b3591eaa2af
展开下载的包文件,Documents文件夹中即有前面生成的文件。