• 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: Sandor Szatmari <email@hidden>
  • Date: Fri, 19 Feb 2016 16:32:20 -0500

Jim,

> On Feb 19, 2016, at 16:17, Jim Adams <email@hidden> wrote:
>
> I have code that looks like the following:
>
> NSArray *sortedEvents = [events.eventSet sortedArrayUsingDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES]]];
>            int64_t csi = -1LL;
>
>            SLogInfo(@"Starting csi %ld count %d", csi, sortedEvents.count);
>
> In the console I see:
> INFO: Starting csi -1 count -1
> The very next line crashes when the sortedEvents are accessed. What could cause the array to have a -1 count?
The return type of -[NSArray count] is NSUInteger so no it is not negative one.  But you are logging it with %d which is for signed integers.  So, certain unsigned values would log as negative one,  unsigned max comes to mind as its twos complement should be negative one when interpreted as signed.

Sandor

>
>
> Note that I am seeing this in a release build so debugging is very difficult.
> _______________________________________________
>
> 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


References: 
 >Can an NSArray ever have a count of -1? (From: Jim Adams <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