• 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: RS: NSObject members class and isMemberOfClass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RS: NSObject members class and isMemberOfClass


  • Subject: Re: RS: NSObject members class and isMemberOfClass
  • From: Fritz Anderson <email@hidden>
  • Date: Fri, 7 Sep 2007 07:58:04 -0500

On Sep 7, 2007, at 5:51 AM, Roland Silver wrote:

While attempting to find a way to determine if an object ostensibly created as an NSMutableArray really is (I can't change it), I wrote this code:
...
	NSArray* arr = [NSArray array];
	NSMutableArray* mut = [NSMutableArray array];
	BOOL test1, test2, test3, test4, test5, test6, test7, test8, test9;
	test1 = ([arr isMemberOfClass:[NSArray class]]);
	test2 = ([mut isMemberOfClass:[NSArray class]]);
	test3 = ([arr isMemberOfClass:[NSMutableArray class]]);
	test4 = ([mut isMemberOfClass:[NSMutableArray class]]);
	test5 = ([mut class] == [NSMutableArray class]);
...

I concur with Mike Abdullah's point that explicit tests of class membership raise a presumption that something is wrong with the design.

But why are you using isMemberOfClass: instead of isKindOfClass:?

	— F

_______________________________________________

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: 
 >RS: NSObject members class and isMemberOfClass (From: Roland Silver <email@hidden>)

  • Prev by Date: Multiple One-to-One Core Data relationships & inverse
  • Next by Date: Re: RS: NSObject members class and isMemberOfClass
  • Previous by thread: Re: RS: NSObject members class and isMemberOfClass
  • Next by thread: Changing button size programmatically
  • Index(es):
    • Date
    • Thread