Re: style question: when to use 'id' as return value?
Re: style question: when to use 'id' as return value?
- Subject: Re: style question: when to use 'id' as return value?
- From: j o a r <email@hidden>
- Date: Mon, 17 Dec 2007 14:58:34 -0800
On Dec 17, 2007, at 2:36 PM, Sean McBride wrote:
I see; makes sense, thanks! But this was just one example, there are
other situations where I don't understand how 'id' was chosen over a
concrete type. For example:
+ (id)sharedGlyphGenerator
vs
+ (ABAddressBook *)sharedAddressBook
Likewise, why does NSWindow's -windowController return 'id' and not
'NSWindowController*'?
I'm trying to understand in general...
I would use this pattern:
* Returning properties of an instance ("-windowController") or of a
class ("+sharedAddressBook")
-> Use the actual type
* Returning new instances from an init method ("-initWithString:"), or
a class factory method ("+stringWithString:")
-> Use "id"
(But as you have noted, Cocoa apparently doesn't agree with me
completely)
There probably should be some official documentation and guidelines
for this, but I don't think there currently is?
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden