On 11 Nov 2010, at 11:57, gMail.com wrote:

> I find this issue very puzzling.
> 
> I read a plist dictionary containing one ony key-value: an NSData coming a
> RTFD string. I read this value, I do NO changes, then I re-save it to a
> different plist file, and now the 2 files are different. I have inspected
> these 2 plist files with TextWrangler, and the difference is at the last
> chars of the <data> object. These chars change 'every time' I save. Why?
> How can I get 2 equal dicts?
> 
> docDictR = [NSDictionary dictionaryWithContentsOfFile:@"/Dict1.plist"];
> textDataR = [docDictR objectForKey:@"textData"];
> mString = [[NSMutableAttributedString alloc] initWithRTFD:textDataR
> documentAttributes:nil];
> 
> // now I save it
> 
> textRangeW = NSMakeRange(0, [mString length]);
> textDataW = [mString RTFDFromRange:textRangeW documentAttributes:nil];
> docDictW = [NSMutableDictionary dictionary];
> [docDictW setObject:textDataW forKey:@"textData"];
> [docDictW writeToFile:@"/Dict2.plist" atomically:YES];
> 
> 
> Dict1.plist last chars of the <data> object
> ALS20y2AQAAAAAAAAAAAAA=
> 
> Dict2.plist last chars of the <data> object
> DHV20y2AQAAAAAAAAAAAAA=
> 
> 
> Regards
> Leonardo


Was the original plist created on another version of OS X?
Might be embedded version info used internally by NSAttributedString.

The NSData rep is private.
NSAttributedString is tool free bridged to CFAttributedString but the latter is 
missing from http://www.opensource.apple.com/source/CF/CF-550/

One solution would be to not resave the NSData rep unless the NSAttributed 
content has actually changed.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to