Re: NSDictionary mutability test
Re: NSDictionary mutability test
On 8 Dec 2008, at 21:25, Bill Bumgarner wrote:
On Dec 8, 2008, at 11:53 AM, email@hidden wrote:
I would disagree. I see nothing wrong with the logically necessity
of testing for mutability. It's just a property.
The AppKit and Foundation were designed with the decision to not
allow for differentiation between mutable and immutable versions of
a class cluster at runtime.
This decisions was purposeful, explicit, and intentional.
I find this an interesting point. Why was such a decision made? It
seems counter intuitive.
Thus, any code that tries to influence behavior based upon detecting
mutable vs. immutable instances will be counter to the design
patterns of the AppKit and Foundation.
And it will be problematic. As has been noted, the AppKit/
Foundation APIs are written such that a method declared as returning
(NSDictionary*) will not have said dictionary modified after the
fact. Writing code that detects mutability and then mutates, if
possible, would violate this contract and will cause unpredictable,
potentially crashy, behavior.
If the intention is to only use this for debugging purposes and to
never influence at runtime behavior based on the mutability of an
object, then the intention is more reasonable. However, this is
still problematic specifically because many classes may return a
mutable object as the result of calling a method that is declared as
returning an instance of the immutable parent.
Thus, such code can really only be reliable when limited to testing
the objects produced by your own code. Potentially valuable, but
only of a limited nature.
b.bum
Jonathan Mitchell
Central Conscious Unit
http://www.mugginsoft.com
_______________________________________________
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