Able to write/read file but unable to delete file SWIFT

半腔热情 提交于 2019-12-01 09:33:11

Your fullPath variable is a (optional) URL. To convert that to a file path string, use the .path property, not string interpolation:

fileManager.removeItem(atPath: fullPath!.path)

Or better, use the URL directly without converting it to a path:

fileManager.removeItem(at: fullPath!)

(And get rid of the forced unwrapping in favor of option binding ... :-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!