gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Heads Up: ABI Change


From: Richard Frith-Macdonald
Subject: Re: Heads Up: ABI Change
Date: Sat, 12 Feb 2011 08:11:56 +0000

On 11 Feb 2011, at 23:50, Stefan Bidi wrote:

> On Fri, Feb 11, 2011 at 5:42 PM, David Chisnall <address@hidden> wrote:
> Hi Stefan,
> 
> I've not looked at the code in detail, but I thought you were creating a 
> private subclass for the old and new behaviours - would it not be possible to 
> simply return a private subclass instance from the constructors and not 
> change the ivar layout of the superclass?
> 
> I really haven't got a clue how to go about getting something like that done. 
>  I'm still at the "getting my feet wet" stage of OOP + ObjC.  I'll have a 
> look at how NSString and it's subclasses are implemented, but I'll probably 
> need someone holding my hand, at least part of the way.

The idea of using a subclass sounds good, and it's quite easy.
I wouldn't recommend looking at NSString as an example though ... that's a 
much, much more complex case than would be needed.

The simple subclassing solution would be to keep the old implementation in the 
base class, and just modify the +allocWithZone: method.
eg.

+ (id) allocWithZone: (NSZone*z)
{
  if (using_new_api && [NSDateFormatter class] == self)
    {
      // If the subclass calls the super implementation, the check for the 
class will prevent recursion.
      return [subclass allocWithZone: z];
    }
  else
    {
      return [super allocWithZone: z];
    }
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]