Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with numbers and property lists



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 setData: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.

References: 
 >Problem with numbers and property lists (From: Nicola Vitacolonna <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.