Re: object type testing
Re: object type testing
- Subject: Re: object type testing
- From: "Lawrence Sanbourne" <email@hidden>
- Date: Sun, 7 May 2006 11:17:32 -0500
On 5/7/06, Ben Dougall <email@hidden> wrote:
regarding finding out if an object instance is a particular type of
class or not
The basic answer is to use -isKindOfClass:, like this:
if ([someObject isKindOfClass:[NSString class]]) {
// Do something stringy with someObject.
}
However, if you just need to know whether you can call some method on
the object, you can be more general and do this:
if ([someObject
respondsToSelector:@selector(myMethod:something:somethingElse:)]) {
// Call myMethod:... on the someObject.
}
Larry
_______________________________________________
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