在Swift中获取UIAlertAction的处理程序 [英] Get handler of UIAlertAction in Swift
问题描述
如何在Swift中获取UIAlertAction
的处理程序.它在初始化时设置,但是我还没有找到任何可以使操作结束的属性.闭包的类型为(UIAlertAction) -> Void
,但是我想获取闭包的内容,这样我就可以像() -> Void
这样使用闭包了.这可能吗?感谢您的回答
How is it possible to get the handler of a UIAlertAction
in Swift. It is set when initializing however I haven't found any property to get hold on the closure of the action. The closure is of type (UIAlertAction) -> Void
however I would like to get the content of the closure so that I have some closure like () -> Void
. Is this possible? Thanks for your answers
推荐答案
UIAlertAction类没有公开任何成员/属性.但是,我们可以通过对UIAlertAction进行子类化来自己进行管理,并指定一个名为"actionHandler"的成员来存储它.
There is NO member/property exposed by the UIAlertAction class. However we can manage this by ourselves by subclassing UIAlertAction and have some member named, say, "actionHandler" to store that.
这篇关于在Swift中获取UIAlertAction的处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!