On Mar 11, 2008, at 14:09, Stuart Malin wrote:
My rationale for departing from the canonical approach is because
then I get a bit of extra type checking at compile time.
Personally I prefer the factory method approach, a la [NSArray array]
etc:
In your header file:
+ (XMPPStream*) xmppStreamWithDelegate: (id)initialDelegate;
In the implementation:
- (id) initWithDelegate:(id)initialDelegate {...}
+ (XMPPStream*) xmppStreamWithDelegate: (id)initialDelegate {return
[[[XMPPStream alloc] initWithDelegate:initialDelegate] autorelease];}
Usage:
someStream = [XMPPStream xmppStreamWithDelegate:delegate];
This (a) gives you the compile time type check, (b) saves a few
keystrokes of clutter wherever you actually create one of these, (c)
forces creation of the object to use a designated initializer without
chance of mistakes, and (d) allows you to use the proper (id) return
type on your initializers.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]