• 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: [Q] Do subclasses implementing same Protocol as super class also need to include it in declaration?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] Do subclasses implementing same Protocol as super class also need to include it in declaration?


  • Subject: Re: [Q] Do subclasses implementing same Protocol as super class also need to include it in declaration?
  • From: Chris Hanson <email@hidden>
  • Date: Wed, 16 Jul 2008 19:31:29 -0700

On Jul 16, 2008, at 2:15 PM, Rick Mann wrote:

I have a class D that derives from class S. S derives from NSObject<NSCoding>. Do I need to declare D as:

	@interface D : S<NSCoding>

or can I leave off the <NSCoding> for the derived classes, and still get appropriate warnings?

You can leave off the <NSCoding> for derived classes, but you won't get warnings because you've said the superclass fulfills the contract described by the protocol declaration.


Subclasses of NSView, for example, all conform to NSCoding because NSView itself does. That's separate from whether subclasses of NSView that want to encode or decode their own unique state need to override NSView's implementation of the appropriate NSCoding methods.

  -- Chris

_______________________________________________

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


References: 
 >[Q] Do subclasses implementing same Protocol as super class also need to include it in declaration? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: notification when app is moved
  • Next by Date: Re: notification when app is moved
  • Previous by thread: Re: [Q] Do subclasses implementing same Protocol as super class also need to include it in declaration?
  • Next by thread: MobileMe upload file to iDisk
  • Index(es):
    • Date
    • Thread