• 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: object type testing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: object type testing


  • Subject: Re: object type testing
  • From: "Keith Ray" <email@hidden>
  • Date: Wed, 10 May 2006 09:54:54 -0700

use –conformsToProtocol: or –respondsToSelector:

I need to be able to determine if a class implements a certain protocol, but some of the classes I will be testing (and would want to reject) are not subclasses of NSObject so they neither implement -conformsToProtocol: nor -respondsToSelector.

NSZombie is one class that my code chokes on (so I have to keep
NSZombies turned off), but there are sometimes others. I don't want to
have to add class categories everytime a new non-NSObject class shows
up to crash my code.

Is there a way to test if a class is a subclass of NSObject (or test
that it implements a certain protocol) that will not crash if the
object is not a subclass of NSObject?

C. Keith Ray
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: object type testing
      • From: Andy Lee <email@hidden>
    • Re: object type testing
      • From: Chris Hanson <email@hidden>
References: 
 >Re: object type testing (From: Erik Buck <email@hidden>)

  • Prev by Date: Re: Does there exist a Cocoa compatibility test tool?
  • Next by Date: C++ gets translated into ObjC? Strange compiler errors...
  • Previous by thread: Re: object type testing
  • Next by thread: Re: object type testing
  • Index(es):
    • Date
    • Thread