• 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: for Loop Error or Logical Error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: for Loop Error or Logical Error?


  • Subject: Re: for Loop Error or Logical Error?
  • From: Nir Soffer <email@hidden>
  • Date: Sun, 24 Dec 2006 19:05:25 +0200


On Dec 23, 2006, at 22:23, Matthew Callis wrote:

I have a loop that is going through an array of sorted items and making a
list of the unique items while counting the instances of them. The error
occurs in that the last unique set of items in the array is not being
counted or listed, even though It IS in the array. The output should have 3
items, not 2.
[snipped long-complex-error-prone-code-with-billion-temporary- variables]

Read first file:///Developer/ADC Reference Library/documentation/ Cocoa/Conceptual/Collections/index.html.


According to the description above, you can do this:

// Assume that tapes is sorted array

NSSet *uniqueTapes = [NSSet setWithArray:tapes];

You can get the count of items with [uniqueTapes count];

If you want a sorted list, implement compare: in Tape, and do this:
NSArray *sortedUniqueTapes = [[uniqueTapes allObjects] sortedArrayUsingSelector:@selector(compare:)];


According to your code, you want to format a tab delimited list of the unique items. Why do you want such list - it this a way to export the data or a way to show the results?


Best Regards,

Nir Soffer

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: for Loop Error or Logical Error?
      • From: "Matthew Callis" <email@hidden>
References: 
 >for Loop Error or Logical Error? (From: "Matthew Callis" <email@hidden>)

  • Prev by Date: Re: for Loop Error or Logical Error?
  • Next by Date: Re: Layers and transparency Core Image
  • Previous by thread: Re: for Loop Error or Logical Error?
  • Next by thread: Re: for Loop Error or Logical Error?
  • Index(es):
    • Date
    • Thread