Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C Runtime

The Objective-C Runtime Reference says:

“Deprecated” below means “deprecated in Mac OS X version 10.5 for 32-bit code, and disallowed for 64-bit code.”

and I would like to use class_setSuperclass in Max OS X version 10.5 even though I still can do it the compiler gives warning telling me its deprecated but it still builds and the Bundle is still usable.

My question is what would be the equivalent in Max OS X 10.5?

like image 860
fernyb Avatar asked Jan 08 '10 22:01

fernyb


1 Answers

On a guess using it is probably not a good idea. I know with the shift towards 64 bit several things in the runtime changed and didn't have a replacement.

The docs even explicitly say not to touch, and doesn't give exception to that.

You can however use class_addMethod to add functionality to a given preexisting class. However, that is also doable via categories.

You can use class_replaceMethod to override a method as well, another possible method is to use a category (or class_addMethod) to add a replacement method. Then using method_exchangeImplementations you can swap them so as to have the original still available for calling.

In general though most of this is kinda dark voodoo, and unless you're comfortable with and willing to test a lot, I'd look for an alternative design.

like image 121
Bryan McLemore Avatar answered Sep 18 '22 23:09

Bryan McLemore