主机应用程序在哪里处理NSExtensionContext#completeRequest? [英] Where does a host app handle NSExtensionContext#completeRequest?
问题描述
当您从分机呼叫completeRequest(returningItems:completionHandler:)
时,主机应用程序在哪里处理?
When you call completeRequest(returningItems:completionHandler:)
from an extension, where does this get handled by the host app?
推荐答案
免责声明:没有检查我的假设,但这可能会有所帮助.
Disclaimer: did not checked my assumptions, but may be this helps.
1)文档指出:
调用completeRequestReturningItems:completionHandler:方法, 通知主机应用其原始请求已完成
Call the completeRequestReturningItems:completionHandler: method, which signals the host app that its original request is complete
2)此处-图2-3显示了"Host" -app-是使用扩展名开始工作的应用程序.例如,主机"可以是用户触摸共享"按钮的应用程序.然后,此主机"应用将一些数据(用户要共享)发送给扩展程序.
2) here - Figure 2-3 shows that "Host"-app - is app that starts some work with extension. For example, "Host" may be the app in which user touches "Share"-button. Then this "Host"-app sends some data (which user wants to share) to extension.
3)我认为,共享数据"扩展是非常常见的扩展示例.很有可能UIActivityViewController
中的某处必须是实现您正在寻找的completeRequest(returningItems:completionHandler:)
以及从扩展名调用的completeRequest(returningItems:completionHandler:)
的方式.
这就是我发现的:
3) "Sharing data"-extension, I think, very common example of extension. So very probable that somewhere in UIActivityViewController
must be way to realise completeRequest(returningItems:completionHandler:)
that you looking for and that called from extension.
And this is what I found:
@property(nullable, nonatomic, copy) UIActivityViewControllerCompletionWithItemsHandler completionWithItemsHandler NS_AVAILABLE_IOS(8_0); // set to nil after call
文档关于此属性的说法:
活动完成或活动视图控制器被解雇后,将执行视图控制器的完成块.
Upon the completion of an activity, or the dismissal of the activity view controller, the view controller’s completion block is executed.
和:
returnedItems- 包含任何已修改数据的NSExtensionItem对象的数组.使用此数组中的项目可获取扩展名对原始数据所做的任何更改
returnedItems - An array of NSExtensionItem objects containing any modified data. Use the items in this array to get any changes made to the original data by an extension
再次,我没有测试.但是此属性看起来就像您要查找的处理程序.
Again, I did not test it. But this property looks like handler you looks for.
这篇关于主机应用程序在哪里处理NSExtensionContext#completeRequest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!