如何在Mac的Cocoa应用程序中允许用户的主文件夹权限 [英] How to allow permission for user's Home folder in cocoa application for mac

查看:64
本文介绍了如何在Mac的Cocoa应用程序中允许用户的主文件夹权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Mac应用程序,正在其中删除用户主目录中的一些数据.

I am having a mac app in which I am deleting some data from user's Home directory.

我的应用被拒绝,原因如下.

My app is rejected saying the below reason.

The app only finds files in the ~/Downloads folder. It would be appropriate to have the user grant access to the Home folder.

因此,我使用NSOpenPanel询问用户的访问权限,但我不知道如何授予对用户隐藏文件夹的访问权限.

So I used NSOpenPanel for asking the access from the user but I have no idea about how to give access to user's hidden folders.

编辑

我已经成功为我的应用启用了沙箱功能,但是现在在允许按钮上,我该怎么办?

I have successfully enabled sandboxing for my app but now on allow button, what should I do?

请为此指导我...

任何帮助将不胜感激.

预先感谢...

推荐答案

我花了一些时间对此进行了研究,我可以说,如果您想要一个能够访问应用程序沙箱外部文件的简单解决方案,那就不会了有可能.

I spent some time researching this and I can say that if you want an easy solution for being able to access files outside your app's sandbox, it's just not going to be possible.

即使您愿意尝试一个更严格,更技术性的解决方案,它仍然可能无法实现.

And even if you were willing to work on a tougher, more technical solution, it is still likely to not be possible.

您应该在Apple的,特别是此位:

You should look at this section in the Apple's App Sandbox Design Guide entitled "Accessing User Data", specifically this bit:

如果您的应用需要访问用户的主目录才能进行功能,使用Apple Bug让Apple知道您的需求报告系统.此外,请务必遵循指导关于iTunes Connect网站上提供的权利.

If your app requires access to the user’s home directory in order to function, let Apple know about your needs using the Apple bug reporting system. In addition, be sure to follow the guidance regarding entitlements provided on the iTunes Connect website.

下一段对其他应用程序的偏好说了同样的话.由于您试图操纵-或删除-其他应用程序的文件,因此您将必须征得Apple的许可和/或指导.

The next paragraph says the same thing about other app's preferences. Since you're trying to manipulate -- or delete -- other app's files, you're going to have to ask Apple for permission and/or guidance to do this.

如果这是我的问题,我可能会尝试提出的唯一解决方法可能是

If this were my problem, the only workaround I might possibly attempt would be to come up with might involve Security-Scoped Bookmarks and Persistent Resource Access, but as you can see from the linked documentation, it's not trivial to setup.

总结:如果您希望您的应用保持沙盒状态,则可能需要重新考虑您要完成的工作.

Summed up: if you want your app to remain sandboxed, you may need to rethink what you are trying to accomplish.

更多信息可以在此 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆