Sunday, February 1, 2015 [Tweets] [Favorites]

Swift & the Objective-C Runtime

Nate Cook:

Unfortunately, a load class method implemented in Swift is never called by the runtime, rendering that recommendation an impossibility. Instead, we’re left to pick among second-choice options:

  • Implement method swizzling in initialize
    This can be done safely, so long as you check the type at execution time and wrap the swizzling in dispatch_once (which you should be doing anyway).

  • Implement method swizzling in the app delegate

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment