I am having the darnedest time trying to figure out how to use CGPathApply with a swift function in Swift 2.2+. I tried it before in Swift 1.2 and it wasn’t possible without bridging to ObjC, but I am fairly sure that changed with Swift 2. Every search I do just comes up with people saying it isn’t possible in Swift 1.
Does anyone know how to pull this off? (I am trying to read in a CGPath and create my own enum-based path struct for easy editing)
Problems are just like any context-based C API, you need to squeeze all
the important stuff into a word-size thing.
Cheers!
Zachary Waldowski
zach@waldowski.me
···
On Thu, May 12, 2016, at 09:04 PM, Jonathan Hull via swift-users wrote:
I am having the darnedest time trying to figure out how to use
CGPathApply with a swift function in Swift 2.2+. I tried it before in
Swift 1.2 and it wasn’t possible without bridging to ObjC, but I am
fairly sure that changed with Swift 2. Every search I do just comes up
with people saying it isn’t possible in Swift 1.
Does anyone know how to pull this off? (I am trying to read in a CGPath
and create my own enum-based path struct for easy editing)
100% right. That solution is by far better if you wanted to work with
the CGPathElement, since that's block-representable. My solution was
assuming (perhaps wrongly) to want to represent it as a Swift type.
You're the best, as always! :)
Cheers!
Zach
···
On Fri, May 13, 2016, at 12:57 AM, Quinn The Eskimo! via swift-users wrote:
On 13 May 2016, at 06:24, Zach Waldowski via swift-users > <swift-users@swift.org> wrote:
> Problems are just like any context-based C API, you need to squeeze all
… and the best way to do that is to use a closure.