NSFileManager.defaultManager().fileExistsAtPath返回false而不是true怎么可能?let exists = NSFileManager.defaultManager().fileExistsAtPath(path.absoluteString)print("exists: \(exists)") //false这是path.absoluteString//file:///Users/kuna/Library/Developer/CoreSimulator/Devices/92BD140D-5C14-43C4-80D6-904BB9594ED6/data/Containers/Data/Application/5B818832-BB19-4047-A7F8-1487F36868D6/Documents/wishlists/68/147/128/IMG_0006.PNG你可以看到它就在它应该在的地方:怎么一回事?
3 回答
HUX布斯
TA贡献1876条经验 获得超6个赞
path
NSURL
path
absoluteString
:
let exists = FileManager.default.fileExists(atPath: path.path)
absoluteString
file:
let url = URL(fileURLWithPath: "/path/to/foo.txt")// This is what you did:print(url.absoluteString)// Output: file:///path/to/foo.txt// This is what you want:print(url.path)// Output: /path/to/foo.txt
青春有我
TA贡献1784条经验 获得超8个赞
let url = NSURL(string: "balabala")let path = url?.path//Check path
慕工程0101907
TA贡献1887条经验 获得超5个赞
file://
file:///Users/kuna/...
/Users/kuna/...
- 3 回答
- 0 关注
- 1503 浏览
添加回答
举报
0/150
提交
取消