- isMemberOfClass:
- respondsToSelector:
- conformsToProtocol:
Availability
Technology
- (BOOL)isKindOfClass:(Class)aClass;
aClass
A class object representing the Objective-C class to be tested.
YES
if the receiver is an instance of a
or an instance of any class that inherits from a
, otherwise NO
.
For example, in this code, is
would return YES
because, in Foundation, the NSArchiver
class inherits from NSCoder
:
Be careful when using this method on objects represented by a class cluster. Because of the nature of class clusters, the object you get back may not always be the type you expected. If you call a method that returns a class cluster, the exact type returned by the method is the best indicator of what you can do with that object. For example, if a method returns a pointer to an NSArray
object, you should not use this method to see if the array is mutable, as shown in the following code:
If you use such constructs in your code, you might think it is alright to modify an object that in reality should not be modified. Doing so might then create problems for other code that expected the object to remain unchanged.
If the receiver is a class object, this method returns YES
if a
is a Class object of the same type, NO
otherwise.
- isMemberOfClass:
- respondsToSelector:
- conformsToProtocol: