• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: From Panther to Tiger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: From Panther to Tiger


  • Subject: Re: From Panther to Tiger
  • From: Shawn Erickson <email@hidden>
  • Date: Mon, 16 May 2005 13:47:46 -0700


On May 16, 2005, at 1:12 PM, Ondra Cada wrote:

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

What document says that mutability is something that would be preserved?

<http://developer.apple.com/documentation/Cocoa/Conceptual/ PropertyLists/Concepts/AboutPropertyLists.html>

What in the plist DTD documents that ability?

-- /System/Library/DTDs/PropertyList.dtd --

<!ENTITY % plistObject "(array | data | date | dict | real | integer | string | true | false )" >
<!ELEMENT plist %plistObject;>
<!ATTLIST plist version CDATA "1.0" >


<!-- Collections -->
<!ELEMENT array (%plistObject;)*>
<!ELEMENT dict (key, %plistObject;)*>
<!ELEMENT key (#PCDATA)>

<!--- Primitive types -->
<!ELEMENT string (#PCDATA)>
<!ELEMENT data (#PCDATA)> <!-- Contents interpreted as Base-64 encoded -->
<!ELEMENT date (#PCDATA)> <!-- Contents should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'. Smaller units may be omitted with a loss of precision) -->


<!-- Numerical primitives -->
<!ELEMENT true EMPTY> <!-- Boolean constant true -->
<!ELEMENT false EMPTY> <!-- Boolean constant false -->
<!ELEMENT real (#PCDATA)> <!-- Contents should represent a floating point number matching ("+" | "-")? d+ ("."d*)? ("E" ("+" | "-") d+)? where d is a digit 0-9. -->
<!ELEMENT integer (#PCDATA)> <!-- Contents should represent a (possibly signed) integer number in base 10 -->


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>

Looks like it is doing the right thing to me. You are asking an immutable class to give you back a tree of objects.


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>

Looks like it is doing the right thing to me. You are asking an mutable class to give you back a tree of objects.


In other words your assumption are wrong and you got bit by it (if think it is needed fill a documentation defect).

-Shawn
_______________________________________________
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


References: 
 >Re: From Panther to Tiger (From: Matt Neuburg <email@hidden>)
 >Re: From Panther to Tiger (From: Bob Ippolito <email@hidden>)
 >Re: From Panther to Tiger (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Spotlight mdimporter + Foundation = "Cannot find function pointer"?
  • Next by Date: Re: From Panther to Tiger
  • Previous by thread: Re: From Panther to Tiger
  • Next by thread: Re: From Panther to Tiger
  • Index(es):
    • Date
    • Thread