Re: Subclassing From Code?
Re: Subclassing From Code?
- Subject: Re: Subclassing From Code?
- From: Matthew Cox <email@hidden>
- Date: Mon, 17 Nov 2003 00:43:24 -0500
On Monday, November 17, 2003, at 12:09 AM, Matthew Cox wrote:
>
You'll need to grab the objc_class record associated with your class,
>
and change its super_class field. I'm not sure how to get a hold of
>
the class definitions. Maybe someone else will fill us in. It must be
>
a private member of the class object, I guess.
I hate it when I look for 15 minutes for the answer to a question, and
find it twenty seconds after I post. If you look in
/usr/include/objc/objc.h, you'll see:
typedef struct objc_class *Class;
Okay, so, I guess something this should work (untested)
[MyClass class].super_class = [NewSuperClass class];
It can't be that simple, can it? You'd best do this before you start
any other threads. It should work even after you've made an object, but
I can't guarantee that this won't result in VERY BAD THINGS. Repeat
after me: I will not abuse the objective-c runtime for my unholy
purposes. I will not abuse the...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.