我不得不a trick帮助测试UIAlertController
,在斯威夫特2.X工作:如何在Swift 3中将__NSMallocBlock__转换为其基础类型?
extension UIAlertController {
typealias AlertHandler = @convention(block) (UIAlertAction) -> Void
func tapButtonAtIndex(index: Int) {
let block = actions[index].valueForKey("handler")
let handler = unsafeBitCast(block, AlertHandler.self)
handler(actions[index])
}
}
这不履行斯威夫特3.X与fatal error: can't unsafeBitCast between types of different sizes
,这诱惑我相信有可能是一种方法,使演员的工作。任何人都可以弄明白吗?
非常有帮助,谢谢! – xytor