• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subclassing From Code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Superclass Changing Wierdness
      • From: Matthew Cox <email@hidden>
    • Re: Subclassing From Code?
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: Re: Subclassing From Code?
  • Next by Date: Formatter - 2 decimal places
  • Previous by thread: Re: Subclassing From Code?
  • Next by thread: Re: Subclassing From Code?
  • Index(es):
    • Date
    • Thread