customizing NSCoding of NSDecimalNumber

  • Hello.

    I want to customize the serialization/coding of NSDecimalNumber so
    that it matches java.mat.BigDecimal in java. I am using HessianObjC.
    The key should be "value" and the value should be the string
    representation of the value.

    I started by overriding "-(id)initWithCoder:" and "-(void)
    encodeWithCoder:", but it looks like my implementation of those
    methods are ignored. Here are the stack-trace.

    #0  0x90a53387 in objc_msgSend ()
    #1  0x0180331c in ?? ()
    #2  0x908103a2 in _CFStringAppendFormatAndArgumentsAux ()
    #3  0x9080ec8c in _CFStringCreateWithFormatAndArgumentsAux ()
    #4  0x925e2a5d in -[NSPlaceholderString
    initWithFormat:locale:arguments:] ()
    #5  0x92604670 in -[NSString initWithFormat:arguments:] ()
    #6  0x9264f337 in +[NSException raise:format:arguments:] ()
    #7  0x9264f2cb in +[NSException raise:format:] ()
    #8  0x92685496 in -[NSDecimalNumberPlaceholder initWithCoder:] ()

    So NSDecimalNumberPlaceholder's "-(id)initWithCoder:" are used
    instead of my. Are the class clustering stuff the reason for this?
    How can I customize the encoding and decoding of a NSDecimalNumber?

      - Tore.
  • On 15 okt 2006, at 22.21, Tore Halset wrote:

    > So NSDecimalNumberPlaceholder's "-(id)initWithCoder:" are used
    > instead of my. Are the class clustering stuff the reason for this?

    Quite likely.

    > How can I customize the encoding and decoding of a NSDecimalNumber?

    You can always externalize your serialization - ie. funnel your
    objects via some support class that knows how to serialize / de-
    serialize them.

    j o a r
  • On Oct 16, 2006, at 7:38, j o a r wrote:

    > On 15 okt 2006, at 22.21, Tore Halset wrote:
    >
    >> How can I customize the encoding and decoding of a NSDecimalNumber?
    >
    > You can always externalize your serialization - ie. funnel your
    > objects via some support class that knows how to serialize / de-
    > serialize them.

    Thanks. Looks like the cleanest solution.

      - Tore.
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today