Re: From Panther to Tiger
Re: From Panther to Tiger
- Subject: Re: From Panther to Tiger
- From: Ondra Cada <email@hidden>
- Date: Mon, 16 May 2005 22:12:14 +0200
Bob,
On 16.5.2005, at 21:54, Bob Ippolito wrote:
Well, does it REALLY surprise you that when you ask an immutable
container class to load itself from disk, you will get an immutable
container back?
Nope, that's not the problem. The problem is that the *contained*
object mutability gets lost in the process!
Does it, to paraphrase your very own words, NOT surprise you the
following simple sample raises? Me, I was surprised all right. In my
vocabulary, this is *WRONG*. But I've kind of got used to that with
CoreData-based stuff :(((
60 /tmp> <uhoh.m
#import <Cocoa/Cocoa.h>
int main() {
[NSAutoreleasePool new];
id o=[NSDictionary dictionaryWithObject:[NSMutableDictionary
dictionary] forKey:@""];
[o writeToFile:@"/tmp/uhoh.plist" atomically:YES];
o=[NSDictionary dictionaryWithContentsOfFile:@"/tmp/uhoh.plist"];
// note: I am NOT trying [o setObject:forKey:]
[[o objectForKey:@""] setObject:@"uhoh" forKey:@"uhoh"];
return 0;
}
61 /tmp> cc -Wall -framework Cocoa uhoh.m && ./a.out
2005-05-16 22:07:51.209 a.out[8667] *** Uncaught exception:
<NSInternalInconsistencyException> *** -[NSCFDictionary
setObject:forKey:]: mutating method sent to immutable object
zsh: trace trap ./a.out
62 /tmp>
And this one (the mirror image of the previous situation) is just as
bad -- this *should* raise, but it does not. Fie.
62 /tmp> <uhoh.m
#import <Cocoa/Cocoa.h>
int main() {
[NSAutoreleasePool new];
id o=[NSMutableDictionary dictionaryWithObject:[NSDictionary
dictionary] forKey:@""];
[o writeToFile:@"/tmp/uhoh.plist" atomically:YES];
o=[NSMutableDictionary dictionaryWithContentsOfFile:@"/tmp/uhoh.plist"];
[[o objectForKey:@""] setObject:@"uhoh" forKey:@"uhoh"];
return 0;
}
63 /tmp> cc -Wall -framework Cocoa uhoh.m && ./a.out
64 /tmp>
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden