• 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
Assessor Syntax: Why use (id with protocol) vs (class name *)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Assessor Syntax: Why use (id with protocol) vs (class name *)?


  • Subject: Assessor Syntax: Why use (id with protocol) vs (class name *)?
  • From: Amourine Tech <email@hidden>
  • Date: Thu, 03 Nov 2011 16:57:09 -0700

Greetings:
   I came across some old ObjC code:

…

1) -----
- (id <ViewOrdersService>)viewOrdersService {
    return [[[ViewOrdersAccessor alloc] init] autorelease];
}

…

2) ---
- (id <AlertsService>)alertsService {
  return [[[AlertsSAXAccessor alloc] init] autorelease];
}

…

Why not use: 

1)  - (ViewOrdersAccessor *)    … and

2)  - (AlertsSAXAccessor *) ?


Is there an advantage to using id <protocol>?
Initially it appears a bit more complicated to work with protocols this versus strong class typing.

Ric.


 _______________________________________________
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: Doug Hill <email@hidden>
    • Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Printing the List of Warnings/Errors as seen within Xcode 4.2
  • Next by Date: Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
  • Previous by thread: Re: Printing the List of Warnings/Errors as seen within Xcode 4.2
  • Next by thread: Re: Assessor Syntax: Why use (id with protocol) vs (class name *)?
  • Index(es):
    • Date
    • Thread