xcode - nsdata 的文件路径
问题描述
我正在尝试从文件路径中获取 NSData,但我不断收到无法打开文件的错误消息。任何想法如何获取路径,以便我可以获取 NSData。
for (int t = 0; t < [self.myarray count]; t++) {
NSURL *url1 = [NSURL fileURLWithPath:[self.myarray objectAtIndex:t]];
NSLog (@"url1: %@", url1);
NSError* error = nil;
NSString *filePath = [url1 path];
NSData* data = [NSData dataWithContentsOfFile:filePath options:NSDataReadingUncached error:&error];
if (error) {
NSLog(@"Data Error: %@", [error localizedDescription]);
} else {
NSLog(@"Data is: %@", data);
}
}
这是错误日志
url1:file:///var/mobile/Containers/Data/Application/85E795CA-B31D-4BD7-A777-DE7B392D6762/Documents/pImw.mp4
数据错误:文件“pImw.mp4”无法打开,因为没有这样的文件。
解决方案
推荐阅读
- python - MNIST 数据集的 Keras 精度不变
- go - redis-cli 如何对在 HLL 或位图上执行 GET 时返回的字符串值进行编码?
- android - 当用户以小写形式输入值时,firebase 搜索查询不起作用,那么它不会返回大写相同的数据
- c++ - 如何使用 xdevapi 从 mysql 获取 DateTime
- c++ - C++ 在变量的内存地址上做了什么来“释放”它?
- javascript - 在 V8 JavaScript 中检测内存分配
- angularjs - 如何从节点红色的角度模板节点传递消息
- php - Laravel - 使用来自 url 的数据进行过滤
- ubuntu - 我如何公开我的 IP,外部可以访问我的本地主机
- android - 向 PagerTitleStrip 添加一个按钮