前言
在使用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."
原因
查看相关源文件

url
必须是一个本地位置,所以需要使用本地文件传输协议File Protocol
。
解决
- var filePath = "file://(fileURLpath)"
- var url:URL = URL.init(fileURLWithPath: str)
参考链接
CFURLCopyResourcePropertyForKey failed because passed URL no scheme
网友评论