Re: object type testing
Re: object type testing
- Subject: Re: object type testing
- From: Todd Blanchard <email@hidden>
- Date: Sun, 7 May 2006 09:03:53 -0700
isKindOfClass: I think tests to see if you are a subclass of a given
class. Its what I have used before.
This is even a bit restricting since it may not tell you all you need
to know to be compatible. For instance, it may be that the object
subclasses NSObject but still implements the protocol you need - so
you can call conformsToProtocol: to see if this is true. If there is
a formal protocol defined, this is probably the best way to check if
the object is what you expect.
On May 7, 2006, at 8:41 AM, Ben Dougall wrote:
hello,
regarding finding out if an object instance is a particular type of
class or not
which should be used out of the following three?:
if( [anObject isMemberOfClass:[AClass class]] ) {
...
if( [anObject class] == [AClass self] ) {
...
if( [[anObject className] isEqualToString:@"AClass"] ) {
...
i suppose the last one is only necessary if you're dealing with
class names in strings, otherwise not necessary. i'm currently
using [anObject class] == [AClass self] but am wondering if it's OK?
thanks, ben
_______________________________________________
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
_______________________________________________
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