Questions about subclassing IOBluetoothOBEXSession
Questions about subclassing IOBluetoothOBEXSession
- Subject: Questions about subclassing IOBluetoothOBEXSession
- From: Paul Davis <email@hidden>
- Date: Sat, 26 Apr 2003 12:00:58 -0400
To whom it may concern:
My goal was to subclass IOBluetoothOBEXSession because I needed some unique
instance variables and methods not contained in this class. There is one
problem. The class method withIncomingRFCOMMChannel cannot be properly used
by a subclass because it is defined as:
+ (IOBluetoothOBEXSession *)withIncomingRFCOMMChannel:
(IOBluetoothRFCOMMChannel*) inChannel
eventSelector:(SEL)inEventSelector
selectorTarget:(id)inEventSelectorTarget
refCon:(void *)inUserRefCon;
With this definition, a subclass of IOBluetoothOBEXSession will always
return the IOBluetoothOBEXSession type instead of the subclass type. It
seems to me that the standard objC approach would have been to define this
class method as follows:
+ (id)withIncomingRFCOMMChannel: (IOBluetoothRFCOMMChannel*) inChannel
eventSelector:(SEL)inEventSelector
selectorTarget:(id)inEventSelectorTarget
refCon:(void *)inUserRefCon
{
id newInstance = [[[self class] alloc] init];
....Do whatever you do to setup an OBEXSession...
return [newInstance autorelease];
}
This way when IOBluetoothOBEXSession is subclassed and the
withIncomingRFCOMMChannel message is received by a subclass, the instance
returned will be the same type as the subclass.
Do you agree? Of course, I found another way to accomplish what I wanted to
do. I would have liked my design better if the withIncomingRFCOMMChannel
method were defined as mentioned.
Regards,
Paul Davis
_______________________________________________
bluetooth-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/bluetooth-dev
Do not post admin requests to the list. They will be ignored.