• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting true 32-bit integers with NSNumber?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting true 32-bit integers with NSNumber?


  • Subject: Re: Getting true 32-bit integers with NSNumber?
  • From: ChanMaxthon <email@hidden>
  • Date: Mon, 02 Dec 2013 17:54:24 +0800

You can check what type int32_t (or uint32_t) is typedef'd to and use that corresponding type on your intended platform. Sort of like:

- (int32_t) int32Value
{
    if (!strcmp(@encode(int32_t), @encode(int))
        return [self intValue];
    else if (!strcmp(@encode(int32_t), @encode(long))
        return [self longValue];
    else
        return 0;
}

Sent from my iPhone

> On 2013年12月2日, at 14:37, Kyle Sluder <email@hidden> wrote:
>
>> On Sun, Dec 1, 2013, at 09:56 PM, Alex Hall wrote:
>> Hello list,
>> I was given a library someone made to use with OpenAL. When he made this,
>> iOS2 was the standard, so naturally it is still 32-bit. I am now trying
>> to use it on OS10, and am getting the expected implicit conversion
>> errors. As far as I can tell, the numbers being used are all 64-bit
>> integers, even when the library calls numberWithUnsignedInt.
>
> It doesn't matter what method you use to create an NSNumber instance.
> What matters is what method you use to get the primitive value back out.
> -intValue and -longValue will give you an int (32 bits); -longLongValue
> will give you a long long (64 bits); and -integerValue will give you an
> NSUInteger (either 32 or 64 bits, depending on your target
> platform―though nowadays you're almost certainly not targeting any
> 32-bit platforms).
>
>> I cannot use ints or uints because this
>> code relies heavily on an NSMutableDictionary, which cannot store
>> primitive data types. Any ideas are appreciated. Thank you.
>
> This is very concerning. I can't imagine it ever being a good idea to be
> storing boxed numbers in an NSDictionary when doing anything
> audio-related. What are you actually doing here?
>
> --Kyle Sluder
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Getting true 32-bit integers with NSNumber?
      • From: Kyle Sluder <email@hidden>
References: 
 >Getting true 32-bit integers with NSNumber? (From: Alex Hall <email@hidden>)
 >Re: Getting true 32-bit integers with NSNumber? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Getting true 32-bit integers with NSNumber?
  • Next by Date: Re: Getting true 32-bit integers with NSNumber?
  • Previous by thread: Re: Getting true 32-bit integers with NSNumber?
  • Next by thread: Re: Getting true 32-bit integers with NSNumber?
  • Index(es):
    • Date
    • Thread