removeItemAtPath - 错误:无法删除,因为您无权访问它

Huy*_*Inc 6 macos cocoa-touch file nsfilemanager ios

我的代码:

NSFileManager.defaultManager().removeItemAtPath(path, error: nil)
Run Code Online (Sandbox Code Playgroud)

我的日志错误:

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
Run Code Online (Sandbox Code Playgroud)

我已经阅读了两个主题,但他们没有解决我的错误.

osx - 如何以编程方式删除具有提升权限的文件?

获取管理员权限以使用来自Cocoa应用程序的rm删除文件

使用Objective-C或Swift的答案都可以.