简体   繁体   English

如何在Mac的Cocoa应用程序中允许用户的主文件夹权限

[英]How to allow permission for user's Home folder in cocoa application for mac

I am having a mac app in which I am deleting some data from user's Home directory. 我有一个Mac应用程序,其中要删除用户主目录中的某些数据。

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.

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. 因此,我使用NSOpenPanel询问用户的访问权限,但我不知道如何授予对用户隐藏文件夹的访问权限。

EDIT 编辑 图片

I have successfully enabled sandboxing for my app but now on allow button, what should I do? 我已经成功为我的应用启用了沙箱功能,但是现在在允许按钮上,该怎么办?

Please guide me on this... 请在这方面指导我...

Any help will be highly appreciated. 任何帮助将不胜感激。

Thanks in advance... 提前致谢...

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. 即使您愿意研究一个更严格,更技术性的解决方案,它仍然可能无法实现。

You should look at this section in the Apple's App Sandbox Design Guide entitled "Accessing User Data" , specifically this bit: 您应该在Apple的“ 应用程序沙箱设计指南”中的标题为“访问用户数据”的这一部分中进行研究,尤其是此位:

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. 如果您的应用程序需要访问用户的主目录才能正常运行,请使用Apple Bug报告系统让Apple知道您的需求。 In addition, be sure to follow the guidance regarding entitlements provided on the iTunes Connect website. 此外,请确保遵循iTunes Connect网站上提供的有关权利的指导。

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. 由于您试图操纵-或删除-其他应用程序的文件,因此您将必须征求Apple的许可和/或指导。

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. 总结:如果您希望您的应用保持沙盒状态,则可能需要重新考虑您要完成的工作。

More information can be found in this related question . 在此相关问题中可以找到更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM