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

Posing as NSPort



NSPort is an abstract class, so no real instances of it should ever 
exist.  When you think you're allocating one, it is allocating an 
instance of a concrete class (like NSMachPort), and of course anything 
typed as NSPort * might be an instance of any subclass of NSPort.

If you subclass an abstract class, you usually have to implement the 
interesting guts of the class; otherwise, the class wouldn't be abstract.

Your posing as NSPort probably is working, but since the concrete 
subclasses may be overriding retain/release for their own purposes, it 
won't do much good.

Chris Kane
Cocoa Frameworks, Apple

On Friday, March 15, 2002, at 12:28 AM, John Saccente wrote:

>
> I want to pose as NSPort to watch retain/release activity during some 
> DO maneuvers, but I'm having no luck.  I get the impression that there 
> is some funny business going on when you create an NSPort object, as I 
> never see any actual instances of "NSPort" listed in ObjectAlloc, only 
> CFMachPorts created in their place.  But clearly I'm manipulating 
> NSPort objects in my code, so this is very confusing.  Using subclassed 
> NSPort objects doesn't work either, since the framework seems to notice 
> that I'm using a subclass in place of a proper NSPort and expects me to 
> implement some special behaviors that I'm ill-prepared to offer.  I 
> have no trouble similarly posing as other classes, but NSPort has me 
> baffled.
>
> John Saccente
> jsaccente@xxxxxxx
>
> _______________________________________________
> MacOSX-dev mailing list
> MacOSX-dev@xxxxxxxxxxxxx
> http://www.omnigroup.com/mailman/listinfo/macosx-dev