isMemberOfClass
isMemberOfClass
- Subject: isMemberOfClass
- From: Roland Silver <email@hidden>
- Date: Thu, 13 Sep 2007 11:34:58 -0600
I hate to keep belaboring the issue of identifying the class of an
object, but consider the following code in view of Apple's
documentation of isMemberOfClass:
id object = [NSArray array];
if ([object isMemberOfClass:[NSArray class]]) {
NSLog(@"object is indeed an NSArray");
} else {
NSLog(@"object is not an NSArray");
}
Is this a bug or am I wedged?
The code works with isKindOfClass instead of isMemberOfClass.
Developer Documentation has this to say:
isMemberOfClass:
Returns a Boolean value that indicates whether the receiver is an
instance of a given class.
- (BOOL)isMemberOfClass:(Class)aClass
Parameters
aClass
A class object representing the Objective-C class to be tested.
Return Value
YES if the receiver is an instance of aClass, otherwise NO.
Discussion
For example, in this code, isMemberOfClass: would return NO:
NSMutableData *myData = [NSMutableData dataWithCapacity:30];
id anArchiver = [[NSArchiver alloc]
initForWritingWithMutableData:myData];
if ([anArchiver isMemberOfClass:[NSCoder class]])
...
-- Roland Silver <email@hidden>
_______________________________________________
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