从另一个应用程序访问Safari书签

从另一个应用程序访问Safari书签

本文介绍了从另一个应用程序访问Safari书签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我们如何才能以一种安全可靠的方式从Mac OS X上的另一个Cocoa应用程序访问Safari书签.

I was wondering how we can access Safari bookmarks from another Cocoa application on Mac OS X, in a way that is safe and secure for the future.

您可能知道,检索Safari书签有两种常见的机制:

As you may know, two mechanisms were common to retreive Safari bookmarks:

  • 要么阅读Safari的Bookmarks.plist文件
  • 或使用SyncServices API.

但是,第一个被沙箱禁止(必须通过App Store进行分发),第二个从Mac OS X 10.7 Lion开始不推荐使用.

However, the first is forbidden by sandboxing (mandatory for a distribution through the App Store), and the second has been deprecated since Mac OS X 10.7 Lion.

我相信Apple不赞成使用SyncServices来支持iCloud同步,但是我找不到任何允许访问书签的iCloud API(1).

I believe that Apple deprecated SyncServices in favour of iCloud synching, but I can't find any iCloud API that allow access to the bookmarks (1).

关于哪里看的任何提示?首选本机可可,但欢迎使用任何不提倡使用的,兼容沙盒的解决方案.

Any hint on where to look? Native Cocoa is preferred, but any non-deprecated, sandboxing-compatible solution is welcome.

谢谢.

(1),说实话,通过互联网(因此需要互联网连接)来在一台机器上检索同一台机器上的某些东西似乎很尴尬,但是,好吧,至少这是一种方法那将是一种可能.

(1) and, honestly, going through the internet (and thus requiring an internet connexion) to retrieve on a machine something on the same machine seems... awkward — but well, if it was the way to go at least that would be a possibility.

推荐答案

即使您明确征得用户的同意,即使在沙箱中运行,您也可以读出书签plist文件:出现一个指向plist目录的打开面板,然后存储您从中收到的安全范围内的书签.我做到了这一点,但我的应用并未因此而被拒绝(但因其他原因而被拒绝).

You can read out the bookmarks plist file even when running in a sandbox if you expressly ask the user for consent: Present an open panel pointing to the plist directory and store the security-scoped bookmark you receive from it. I did this and my app wasn't rejected for this (but for other things).

这篇关于从另一个应用程序访问Safari书签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:14