• 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
isMemberOfClass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: isMemberOfClass
      • From: Scott Thompson <email@hidden>
  • Prev by Date: Re: Parallel instances of Cocoa apps?
  • Next by Date: Re: isMemberOfClass
  • Previous by thread: Best way to access data when subclassing NSTableView?
  • Next by thread: Re: isMemberOfClass
  • Index(es):
    • Date
    • Thread