Is there any way to give Apple feedback on their APIs?

Discussion in 'Mac Programming' started by foidulus, Sep 19, 2010.

  1. macrumors 6502a

    Joined:
    Jan 15, 2007
    #1
    I just have a little niggling complaint, namely that it isn't possible to wrap (u)int(32/64)_t objects into NSNumber objects(easily, I came up with a solution but its not pretty and not really cross platform).

    It would be wonderful if we could pass around NSNumber objects and KNOW their size regardless of the platform we are on.

    Is there any way I could contact Apple and ask for something like this? Has anyone ever had any luck doing so?
     
  2. macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    bugreport.apple.com is probably one of the easiest ways to communicate directly with Apple's developers. Try filing an enhancement request.
     
  3. macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #3
    Why not subclass NSNumber or make a category on it. Or make your own class and pass that object.
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    This doesn't seem difficult at all.

    Call -objCType on the NSNumber, and dereference the returned char*, decoding it according to:
    https://developer.apple.com/library...html#//apple_ref/doc/uid/TP40008048-CH100-SW1

    You could probably put the whole decoding procedure in a single function like:
    Code:
    extern size_t sizeOfNumber(NSNumber*);
    Or maybe add it as a category of NSNumber. Either way, make sure you handle NSDecimalNumber properly (read its class reference doc).

    If you want further suggestions, post the code for your solution, and examples of its use in real-life contexts. My first thought was -objCType, which seems to easily solve the problem stated, so maybe something about the difficulty isn't clear from your description, which would be more apparent by seeing code.
     
  5. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #5
    Code:
    + numberWithLongLong:(long long)value
    will accept any signed integer type and return an NSNumber object with the given value.

    Code:
    + numberWithUnsignedLongLong:(unsigned long long)value
    will accept any unsigned integer type and return an NSNumber object with the given value.

    Completely portable.
     
  6. thread starter macrumors 6502a

    Joined:
    Jan 15, 2007
    #6
    Yep, my mistake. I assumed that unsigned long longs were like ints, ie they were different sizes on different architectures. But it turns out that they are not(printed out a sizeof(long long) on both i386 and x864_64), mea culpa.
     
  7. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #7
    Well, they are not guaranteed to be always the same size; they might become 128 bits in ten years time, but the point is that they are _always_ big enough to hold a uint32_t or uint64_t. "long long" is guaranteed to be at least 64 bits. "long" is guaranteed to be at least 32 bits, so you can portably use it to store an int32_t. Apple guarantees that it is big enough to hold an NSInteger.
     
  8. macrumors member

    Joined:
    Aug 8, 2005
    #8
    I don't know how it is in the C/Obj-C spec, but surely it can't be too much different than the C++ spec. But anyway, from what I know, the definition of the size of integers (and their varieties) are up to the compiler and are merely related to whatever size they choose for an int. Might be worth looking into further if it is highly related to the work you're doing?
     

Share This Page