Re: why does this method return an id?
Re: why does this method return an id?
- Subject: Re: why does this method return an id?
- From: Charles Srstka <email@hidden>
- Date: Sun, 11 Dec 2011 13:01:31 -0600
On Dec 11, 2011, at 12:51 PM, Kyle Sluder wrote:
> On Sun, Dec 11, 2011 at 10:41 AM, Ben Kennedy <email@hidden> wrote:
>> On 11 Dec 2011, at 8:58 am, Matt Neuburg wrote:
>>
>>> Now, I think I know why [NSString string] is declared as returning an id - it's because it's a class cluster,
>>
>> Despite this however, why then don't the cluster classes implement a protocol (e.g. one named NSString), and then NSString can return an id<NSString> rather than a plain id?
>
> Because it's a pain in the ass to define a protocol for each class
> with a convenience constructor that you expect might be subclassed.
>
> In ToT clang we now have the `instancetype` keyword that can replace
> the `id` keyword in most of these cases:
> http://clang.llvm.org/docs/LanguageExtensions.html#objc_instancetype
Now that is a nice addition!
Charles_______________________________________________
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