美文网首页
Swift3.0 文件写入时 no scheme

Swift3.0 文件写入时 no scheme

作者: 知忧丶 | 来源:发表于2017-06-05 16:35 被阅读551次

前言

在使用Swift进行文件读取时系统输出错误: CFURLCopyResourcePropertyForKey failed because it was passed an URL which has no scheme. Error Domain=NSCocoaErrorDomain Code=518 "The file couldn’t be saved because the specified URL type isn’t supported."

原因

查看相关源文件

Data
url必须是一个本地位置,所以需要使用本地文件传输协议File Protocol

解决

  • var filePath = "file://(fileURLpath)"
  • var url:URL = URL.init(fileURLWithPath: str)

参考链接

CFURLCopyResourcePropertyForKey failed because passed URL no scheme

相关文章

网友评论

      本文标题:Swift3.0 文件写入时 no scheme

      本文链接:https://www.haomeiwen.com/subject/ulzifxtx.html