• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
      • From: Amourine Tech <email@hidden>
References: 
 >Assessor Syntax: Why use (id with protocol) vs (class name *)? (From: Amourine Tech <email@hidden>)

  • Prev by Date: Assessor Syntax: Why use (id with protocol) vs (class name *)?
  • Next by Date: Re: Learning the Interface Builder
  • Previous by thread: Assessor Syntax: Why use (id with protocol) vs (class name *)?
  • Next by thread: Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
  • Index(es):
    • Date
    • Thread