Hacker News new | ask | show | jobs
by jdmoreira 856 days ago
> Method swizzling is also an important tool for any aspiring macOS developer, unavailable/onerously painful in Swift.

I use swizzling in Swift. Can't see why it's more painful than in Objective-C. It's also not something you do all the time. It's basically write once code for me.

Funny enough I mostly use it so swizzle UIViewController lifecycle methods and then just pass closures in instead of subclassing UIViewController. Yes, I don't subclass UIViewController and haven't for years and years. (I mostly don't subclass that much nowadays - take that Objective-C!)

1 comments

Yeah, it’s exactly the same function calls. Swift C interop is pretty decent, especially when dealing with apples own calls.