英文:
How to add Actions to MACOS FileProvider API and use them in the Code?
问题
我正在开发一个涉及到FileProvider API的macOS项目。我想要向由FileProvider提供的项目添加自定义操作,并在我的代码中使用它们。我该如何实现这个目标?
具体来说,我想知道:
- 如何向macOS FileProvider API添加操作?
- 如何定义和自定义这些操作?
- 如何在我的代码中处理所选操作的执行?
- 如何访问并在我的代码中使用这些操作?
我已经在我的Xcode项目中创建了一个File Provider扩展目标,并实现了必要的协议。我只需要指导如何使用FileProvider API添加和利用这些操作。
我会感激任何示例代码或逐步说明,以帮助我理解和实现这个功能。谢谢!
英文:
I'm working on a macOS project that involves the FileProvider API. I would like to add custom actions to the items provided by the FileProvider and use them in my code. How can I achieve this?
Specifically, I want to know:
How can I add actions to the macOS FileProvider API?
How can I define and customize these actions?
How can I handle the execution of the selected actions in my code?
How can I access and use these actions in my code?
I've already created a File Provider extension target in my Xcode project and implemented the necessary protocols. I just need guidance on how to add and utilize actions with the FileProvider API.
I would appreciate any example code or step-by-step instructions to help me understand and implement this functionality. Thank you!
答案1
得分: 0
我在这里找到了答案:https://developer.apple.com/documentation/fileproviderui/adding_actions_to_the_context_menu
并且你可以像这样使用它,使用 performAction() 方法:
func performAction(identifier actionIdentifier: NSFileProviderExtensionActionIdentifier,
onItemsWithIdentifiers itemIdentifiers: [NSFileProviderItemIdentifier],
completionHandler: @escaping (Error?) -> Void) -> Progress {
switch actionIdentifier.rawValue {
}
}
英文:
I found my answer here: https://developer.apple.com/documentation/fileproviderui/adding_actions_to_the_context_menu
and you can use it like this using performaction()
func performAction(identifier actionIdentifier: NSFileProviderExtensionActionIdentifier,
onItemsWithIdentifiers itemIdentifiers: [NSFileProviderItemIdentifier],
completionHandler: @escaping (Error?) -> Void) -> Progress {
switch actionIdentifier.rawValue {
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论