Re: NSArray cluster class membership
Re: NSArray cluster class membership
- Subject: Re: NSArray cluster class membership
- From: Ali Ozer <email@hidden>
- Date: Sat, 6 Mar 2004 13:48:51 -0800
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".
Well, there is this:
// This function is for Foundation's benefit; no one else should use
it.
Boolean _CFArrayIsMutable(CFArrayRef array)
But as the comment says, you shouldn't use it.
First of all, this function only works on CFArrays, and not on
instances of arbitrary subclasses of NSArrays. Secondly, this function
is likely to go away in the next release, so indeed - please don't use
it.
As far as overrides of isKindOfClass:, respondsToSelector:, etc to get
built-in NSArray subclasses to return "proper" results --- these kinds
of hacks can also prove troublesome, and the benefits are outweighed by
the potential issues. So we don't have them.
In addition, there is indeed no API for finding out whether an array is
mutable or not, as such API is often misused (not always, but
unfortunately often...). What you know from the API you got the array
from is what you can assume; anything else is dangerous as you might
end up mutating someone elses data structures.
If you created a mutable array yourself, and want to keep track of the
fact that it's mutable, it's best to have an extra bool on the side.
Ali
_______________________________________________
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.