Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
- Subject: Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
- From: Jens Alfke <email@hidden>
- Date: Thu, 03 Nov 2011 17:22:35 -0700
On Nov 3, 2011, at 4:57 PM, Amourine Tech wrote: Is there an advantage to using id <protocol>?
It’s the same reason why protocols (and Java interfaces, which were inspired by them) exist: to allow multiple implementations that don’t have to share a common base class. If the method were declared as returning ViewOrdersAccessor*, then (a) it couldn’t be overridden to return some other implementation of ViewOrdersService, and (b) the implementation couldn’t be changed to return some other implementation without altering the interface, which might break clients.
—Jens |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden