• 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: Can an NSArray ever have a count of -1?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can an NSArray ever have a count of -1?


  • Subject: Re: Can an NSArray ever have a count of -1?
  • From: Marco S Hyman <email@hidden>
  • Date: Fri, 19 Feb 2016 15:46:04 -0800

>> On Feb 19, 2016, at 4:29 PM, Jens Alfke <email@hidden> wrote:
>>
>> NSInteger is a typedef of ‘long’ in 64-bit, and ‘int’ in 32-bit.
>> You’re correct that %d should be used for NSInteger in 32-bit.
>
> The recommended way to use an NSInteger, as per Apple documentation, is to use %ld and explicitly cast it to long.
>
> NSLog(@“foo is %ld”, (long)foo);
>
> This will work regardless of platform.
>
> For NSUInteger, you use %lu and cast to unsigned long.

This was posted on the xcode list a while back by Quincey Morris:

"As suggested by Greg Parker on this list a couple of years ago, you can use

	%t… (%td, %to, %tu %tx, %tX) for unsigned results
	%z… (%zd, %zo, %zu %zx, %zX) for signed results

and these work on NS[U]Integer-sized variables on all platforms and    architectures that are supported by Apple (without having to cast the parameters).”

They are documented in (all version I think) of the String Programming Guide.
_______________________________________________

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


References: 
 >Can an NSArray ever have a count of -1? (From: Jim Adams <email@hidden>)
 >Re: Can an NSArray ever have a count of -1? (From: Jens Alfke <email@hidden>)
 >Re: Can an NSArray ever have a count of -1? (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Can an NSArray ever have a count of -1? (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Can an NSArray ever have a count of -1?
  • Next by Date: Re: Can an NSArray ever have a count of -1?
  • Previous by thread: Re: Can an NSArray ever have a count of -1?
  • Next by thread: Re: Can an NSArray ever have a count of -1?
  • Index(es):
    • Date
    • Thread