Re: NSArray cluster class membership
Re: NSArray cluster class membership
- Subject: Re: NSArray cluster class membership
- From: Marco Scheurer <email@hidden>
- Date: Wed, 3 Mar 2004 00:17:23 +0100
To followup on my own post: I'm aware that the NSArray cluster is
implemented with a CFArray that is used for both NSArray and
NSMutableArray instances. This also has been discussed previously on
this list (see for instance the Mutable class problems thread).
I was under the impression that some of these issues had been fixed,
following one of these previous discussions. Semantically, given the
class hierarchy, [[NSArray array] isKindOfClass:[NSMutableArray class]]
should return NO independently of implementation details like CFArray.
It looks like I must have been hallucinating...
Thanks,
marco
On Mar 2, 2004, at 10:51 PM, Marco Scheurer wrote:
Hello list,
I was browsing the "Porting OGo to MacOSX" page at
http://www.opengroupware.org/en/projects/macosx/ where I found:
"on Cocoa we cannot find out whether an array is mutable - affects
NGObjWeb and is hacked around using NS_DURING".
I was sure that this had been corrected in a recent release of Mac OS
X, but apparently not. I typed the unit tests below and sure enough,
some tests fail:
Lab/Test.m:17: -[Test testClassMembership] : [[NSArray array]
isMemberOfClass:[NSArray class]] should be true
Lab/Test.m:18: -[Test testClassMembership] : [[NSArray array]
isKindOfClass:[NSMutableArray class]] should be false
Lab/Test.m:22: -[Test testClassMembership] : [[NSMutableArray array]
isMemberOfClass:[NSMutableArray class]] should be true
Lab/Test.m:26: -[Test testClassMembership] : [[NSArray array]
respondsToSelector:@selector(addObject:)] should be false
The errors with isMemberOfClass: can be explained because the cluster
actually returns an instance of a subclass of NSArray for [NSArray
array]. It's still shocking from a semantic point of view, and I'm not
sure what would be lost if [[NSArray array] isMemberOfClass:[NSArray
class]] returned YES, but OK, maybe it's a price to pay for clusters.
It's even worse for the 2 others, but as I said, I was pretty sure
these had been fixed (ie, isKindOfClass: and respondsToSelector: had
been tweaked to return the correct result). Was it a dream?
[...]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.