简体   繁体   English

iOS NSFileManager使用URL而不是路径将文件存储在Document目录中吗?

[英]iOS NSFileManager Store file in Document directory using URLs not Paths?

Apple says it's better to use URLs to access files stored in the phone. 苹果表示,最好使用URL访问手机中存储的文件。 But I can't find a method to create a new file at URLs. 但是我找不到在URL上创建新文件的方法。 Are there Any? 有吗 Or we must create file using a path and retrieve them using an URL ? 还是我们必须使用路径创建文件并使用URL检索它们?

Thanks! 谢谢!

要将文件路径转换为URL,请使用fileURLWithPath类方法,如下所示:

NSURL *filePathURL = [NSURL fileURLWithPath:filePath];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM