【问题标题】:Cocoa : Add app to startup in sandbox using pyobjcCocoa:使用 pyobjc 将应用程序添加到沙箱中的启动
【发布时间】:2014-10-06 09:59:10
【问题描述】:

我正在尝试为用户提供从登录时开始的选项。但是,当我在没有沙箱的情况下运行应用程序时,下面的代码可以正常工作,但它不能在启用沙箱的情况下工作。我在控制台中看到:SFL(8490): AddNewItemWithProperties_rpc 返回 5

def open_app_at_startup():
    app_path = NSBundle.mainBundle().bundlePath()
    url = NSURL.alloc().initFileURLWithPath_(app_path)
    login_items = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)
    props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden)
    v = LSSharedFileListInsertItemURL(login_items,
                                      kLSSharedFileListItemLast,
                                      None,
                                      None,
                                      url,
                                      props,
                                      None)

【问题讨论】:

    标签: objective-c cocoa pyobjc appstore-sandbox


    【解决方案1】:

    https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html#//apple_ref/doc/uid/10000172i-SW5-SW1

    解决方案是,如果我们想对应用进行沙盒处理,我们需要使用服务管理框架而不是共享文件列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-20
      • 1970-01-01
      • 1970-01-01
      • 2011-02-14
      相关资源
      最近更新 更多