• 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: NSCoding protocol
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCoding protocol


  • Subject: Re: NSCoding protocol
  • From: "Michael Ash" <email@hidden>
  • Date: Sat, 11 Oct 2008 14:37:42 -0400

On Fri, Oct 10, 2008 at 12:52 PM, Negm-Awad Amin <email@hidden> wrote:
> Yup, you are complelty right. The correct code:
>
> if( [BaseClass instancesRepondsToSelector@selector( initIWithCoder: )] ) {
> …

If you want to get really fun, you can check it thus:

if([super.class instancesRespondToSelector:...])

This works because the 'super' keyword just gives you a struct of type
objc_super, and you can access its members directly. (Note that in
ObjC++ you will have to use super.super_class instead.) The advantage
here is that you aren't hardcoding the name, so if you change what
class you derive from the code will continue to work as intended.

And before anyone jumps in, [self superclass] will *not* work, because
it fails if 'self' is an instance of a subclass of your class.

Mike
_______________________________________________

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: 
 >NSCoding protocol (From: email@hidden)
 >Re: NSCoding protocol (From: Negm-Awad Amin <email@hidden>)
 >Re: NSCoding protocol (From: "Clark Cox" <email@hidden>)
 >Re: NSCoding protocol (From: Negm-Awad Amin <email@hidden>)

  • Prev by Date: Re: NSNull and @""
  • Next by Date: Re: NSNull and @""
  • Previous by thread: Re: NSCoding protocol
  • Next by thread: Multiples calls to acceptsFirstResponder
  • Index(es):
    • Date
    • Thread