我的代码:
NSFileManager.defaultManager().removeItemAtPath(path, error: nil)
我的日志错误:
NSUnderlyingError=0x618000255900 "The operation couldn’t be completed. Permission denied"})
“SecureDelete Lite” couldn’t be removed because you don’t have permission to access it
我已阅读了两个主题,但他们无法解决我的错误。
osx - How to programmatically delete a file with elevated privileges?
Obtaining admin privileges to delete files using rm from a Cocoa app
使用Objective-C或Swift的答案都可以。