• 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: swizzling a class to a subclass inorder to add ivars (& methods) to a class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class


  • Subject: Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class
  • From: Bill Bumgarner <email@hidden>
  • Date: Wed, 1 Nov 2006 21:08:41 -0800

On Nov 1, 2006, at 7:39 PM, Dustin Robert Kick wrote:
Can you access:
struct objc_ivar_list *ivars;
from a class, taking it and an objc_ivar_list that you create, and set the "ivars" of the class to be a new objc_ivar_list created by appending the original, and the new ivars you wish to add?


struct objc_ivar_list * newlist = (objc_ivar_list *) malloc (sizeof (original_list) + sizeof(new_list));
then set all the ivars?


Something like that?

Well... you *could* do that, but it buys you very little.

First, it'll break all subclasses. Objective-C suffers from the fragile base class issue in regards to instance variables. You simply can't change the layout of the ivars of a class without requiring all subclasses and categories (that access the ivars) to also be recompiled in light of that new layout.

b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class (From: Dustin Robert Kick <email@hidden>)

  • Prev by Date: Re: Core data, array controller, and add:
  • Next by Date: distinctUnionOfSets operator with mutableSetValueForKeyPath:?
  • Previous by thread: Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class
  • Next by thread: Re: swizzling a class to a subclass inorder to add ivars (& methods) to a class
  • Index(es):
    • Date
    • Thread