Re: Problem with numbers and property lists
Re: Problem with numbers and property lists
- Subject: Re: Problem with numbers and property lists
- From: Chris Kane <email@hidden>
- Date: Sun, 29 Dec 2002 16:50:22 -0800
On Wednesday, December 25, 2002, at 10:00 AM, Nicola Vitacolonna wrote:
Nobody having problems with NS(Decimal)Numbers and property lists?
I have an NSTable that displays formatted real numbers (cells have an
NSFormatter attached).
[...]
Please help me, because this is somewhat frustrating. Should
NSDecimalNumbers be property list objects, in that they are a subclass
of NSNumber? Or am I assuming something wrong?
You can check the property-list-ness of an object (say, the top-level of
your plist) using the NSPropertyListSerialization class in 10.2. If
your NSDecimalNumbers are not accepted as number objects (and they
probably should be), that's the problem. If they are accepted, they are
still going to be subject to two effects: (1) loss of precision and
actual value for very large or small values, outside the ordinary range
of a double NSNumber, and (2) when the objects are recreated from the
flattened form, they will be NSNumbers not NSDecimalNumbers (plist
serialization does not preserve class).
Archiving is also a solution for your the pasteboard. Instead of using
setPropertyList:forType: you should archive to an NSData and use
set
Data:forType: (and of course dataForType: on the read end).
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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.