After migrating to Swift 2, I am getting this issue with an error stating that I should now use @convention(c) (T) -> U. I've tried permutations but so far no luck.
func foo(context: AnyObject?, width: CGFloat) -> Int {
}
let bar = unsafeBitCast(foo, CFunctionPointer<(UnsafeMutablePointer<Void>, Float) -> Int>.self)
You no longer need to create a CFunctionPointer in Swift 2. Instead, you can annotate your type by calling convention, in this case
c
, and use it directly.The relevant bits of the
@convention
description in the Type Attributes section of The Swift Programming Language are: