discuss-gnustep
[Top][All Lists]
Advanced

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

Re: problem with poseAs


From: David Ayers
Subject: Re: problem with poseAs
Date: Thu, 05 May 2005 11:41:08 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414

Lloyd Dupont wrote:

> Assertion failed: impostor->instance_size == super_class->instance_size, 
> file class.c, line 638
> 
> I'm kind of puzzled, couldn't you have new instance variable in a posing 
> subclass?
> That's the whole advantage compare to categories...

Actually, the advantage is that you can override methods and call super
instead of replacing the class' implementation or potentially
conflicting with other categories.

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSObject.html#//apple_ref/doc/uid/20000050-poseAsClass_

But maybe someone can find the time to update our documentation to
clarify this issue.

> How could I work around that?
> I need paragraph style information extensoively and absolutely, I can't 
> simply remove the code using it.... 

Well I guess there are a few alternatives with varying implications.  If
there are not many NSMutableParagraphStyles and the code isn't very hot,
I'd first consider a static global NSMapTable for pointers or GSIMap for
scalars looked up by the objects address.

But if you really need to keep the ivar local, then instead of adding
the ivar in the header, I think you may have to hack the runtime-time
structures to change instance size and ivar structures and worry about
anyone that may have cached this information... And all this has to be
done before the first instance is allocated.  Then you need to probably
use some a custom struct and pointer casting for accessing the ivar.  It
can get pretty hairy, but it's theoretically possible.

Cheers,
David





reply via email to

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