> On Sep 24, 2016, at 8:11 AM, Patrick J. Collins > <[email protected]> wrote: > > When I run this, I get 0 instead of 123.
Right; you’ve created a new, different ivar in the subclass, which just happens to have the same name. > Is there a way I can get access to the _wut ivar in the base class Yes, by using the power of <objc/runtime.h>. This is a super-powerful API that lets you open up and mess with classes like Legos. You can find the ivars and methods, modify variables, even create and remove methods and create new classes. Looks like the function you’ll need is object_setInstanceVariable. Obviously this great power should be used responsibly. I’d only recommend doing this as a last resort, if there’s no way to modify the library yourself. Also, if it's a system library, be careful because the library’s implementation could change in any future OS release and invalidate your hack, breaking your app. —Jens
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com This email sent to [email protected]
