私はスウィフト2.xの中で働いていたテストUIAlertController
を助けるためにa trickを持っていた:__NSMallocBlock__をSwift 3の基になる型にキャストするにはどうすればよいですか?
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])
}
}
これは、鋳造作業を作るための方法があるかもしれないと信じて私を誘惑fatal error: can't unsafeBitCast between types of different sizes
スイフト3.xの、下に失敗します。誰もそれを把握できますか?
非常に助かりました、ありがとう! – xytor