Apple has deprecated NSObject
's poseAsClass:
method for OS X v10.5 and above. Is there another way to make class posing work?
I don't think there is a class-level equivalent, but you can exchange the implementation of two methods, which was often the purpose of using poseAsClass:
(of course, you can exchange more than one method if you need to override multiple methods in a class). You want method_exchangeImplementations in the Objective-C 2.0 runtime (#import objc/runtime.h
). A word of warning: after calling method_exchangeImplementations, calling the 'new' method actually calls the original method definition.
Lap Cat gives an alternative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With