相关疑难解决方法(0)

如何在Snow Leopard中编写Finder插件

无论我到哪里,我都看到在Snow Leopard中编写Finder插件比在Leopard中更容易.有人能指点我可以下载的一些教程或简单的代码示例吗?

我正在尝试为Finder编写客户右键单击菜单项.

macos plugins finder objective-c osx-snow-leopard

6
推荐指数
1
解决办法
2349
查看次数

如何在OS X服务菜单中自动激活项目

我需要在服务菜单中默认启用我创建的服务.

我为我的OS X应用程序(在Snow Leopard上运行)创建了一项服务.我已经像这样配置了Info.plist:

<key>NSServices</key>
<array>
    <dict>
        <key>NSSendTypes</key>
        <array>
            <string>NSStringPboardType</string>
        </array>
        <key>NSMessage</key>
        <string>dropService</string>
        <key>NSMenuItem</key>
        <dict>
            <key>default</key>
            <string>Drop Service</string>
        </dict>
        <key>NSPortName</key>
        <string>MyApp</string>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我遵循以下其他步骤:http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/introduction.html,一切似乎都正常.

我跑了命令:

/System/Library/CoreServices/pbs
Run Code Online (Sandbox Code Playgroud)

现在我的服务显示在"系统偏好设置 - >键盘 - >键盘快捷键 - >服务"下.所以系统知道它.但它不会显示在服务菜单中,除非我手动激活它.

当我尝试调试服务时,我收到以下消息:

/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.myapp.MyApp
Drop Service (com.myapp.MyApp) is disabled in the services menu and disabled in the context menu, by the standard Services policy.
Run Code Online (Sandbox Code Playgroud)

我不知道"标准服务政策"是什么,我在Apple开发者网站上找不到任何对此错误的引用.

我认为自动启用服务项是不可能的,但我已经确认某些应用程序会这样做(比如来自文化代码的东西)所以我知道它可以完成.

有任何想法吗?

macos cocoa objective-c

3
推荐指数
2
解决办法
3772
查看次数

在Finder上下文中建立服务

我正在尝试使用此类向Finder的上下文菜单添加服务:

public class Service {
  public func handleServices(pboard:NSPasteboard, userData:String, error:UnsafeMutableBufferPointer<String>) {  // not sure about the correct parameters
    if (pboard.types?.contains(NSFilenamesPboardType) != nil) {
      let fileArray = pboard.propertyListForType(NSFilenamesPboardType)
      print(fileArray)
    }
  }

  init () {
    NSApp.servicesProvider = self
    NSUpdateDynamicServices()
  }
}
Run Code Online (Sandbox Code Playgroud)

该服务在info.plist中公布如下:

<key>NSServices</key>
<array>
    <dict>
        <key>NSMenuItem</key>
        <dict>
            <key>default</key>
            <string>Service Handling Demo</string>
        </dict>
        <key>NSMessage</key>
        <string>handleServices</string>
        <key>NSPortName</key>
        <string>services</string>
        <key>NSSendTypes</key>
        <array>
            <string>NSFilenamesPboardType</string>
        </array>
    </dict>
</array>
Run Code Online (Sandbox Code Playgroud)

最后,我在系统偏好设置/键盘/快捷方式中打开了该服务.所以我看到了服务并且可以调用它.但是我在打电话时得到的只是

找不到选择器handleServices的服务提供者:userData:error:或handleServices :: for service handleServices

service finder contextmenu swift

2
推荐指数
1
解决办法
800
查看次数