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

Re: isMemberOfClass


  • Subject: Re: isMemberOfClass
  • From: Scott Thompson <email@hidden>
  • Date: Thu, 13 Sep 2007 12:41:09 -0500


On Sep 13, 2007, at 12:34 PM, Roland Silver wrote:

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?

This is certainly not a bug. NSArray is a class cluster :

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_9.html

As a result when you call [NSArray array] you don't know which of the classes in the cluster the returned object is a part of.

In general, it's a very Bad Idea(tm) to rely on the identity of a class anyway. It usually represents a software design flaw elsewhere. Why do you need to know the class of an object?


_______________________________________________

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


References: 
 >isMemberOfClass (From: Roland Silver <email@hidden>)

  • Prev by Date: isMemberOfClass
  • Next by Date: Re: custom view won't update
  • Previous by thread: isMemberOfClass
  • Next by thread: Recreating Finder launch animation
  • Index(es):
    • Date
    • Thread