Last active
November 2, 2016 20:42
-
-
Save gottesmm/c6d50f863b9264f093a2451ebbeb976c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
typealias CallbackBlock = @convention (block) () -> Void | |
func main() -> CallbackBlock { | |
let handler: CallbackBlock = { print("yes") } | |
let x = NSMutableDictionary() | |
x["foo"] = handler | |
let handler2 = x["foo"] as! CallbackBlock | |
return handler2 | |
} | |
let _ = main() | |
func main2() -> CallbackBlock { | |
let handler: CallbackBlock = { print("yes") } | |
let x = NSMutableDictionary() | |
x["foo"] = handler | |
let handler2 = unsafeBitCast(x["foo"] as AnyObject, to: CallbackBlock.self) | |
return handler2 | |
} | |
let _ = main2() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment