Re: Convenience Methods
Re: Convenience Methods
- Subject: Re: Convenience Methods
- From: Chris Suter <email@hidden>
- Date: Wed, 26 Sep 2007 12:47:33 +1000
On 26/09/2007, at 11:46 AM, Jeff Laing wrote:
There is no way the class method is going to return subclasses.
Yes there is.
If you call [MySubclass repoWithName:…] you'd get an instance of
MySubclass. You don't need to override the class method for it to do
this.
And with regards to the original question, you shouldn't use "id" as
the return type. The class cluster issue mentioned in other posts is
confusing the issue. NSString methods are declared as returning
NSString * not id. This is because you want the compiler to know as
much about the type as possible i.e. that the object returned
conforms to all the methods declared by NSString. The fact that it's
a different class underlying this doesn't matter — the object
returned conforms to NSString.
- Chris
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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