Re: RS: NSObject members class and isMemberOfClass
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