• 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: Searching array with block
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Searching array with block


  • Subject: Re: Searching array with block
  • From: Fritz Anderson <email@hidden>
  • Date: Sun, 11 Nov 2012 17:05:14 -0600

On 11 Nov 2012, at 4:30 PM, Erik Stainsby <email@hidden> wrote:

> in spite of having 51 records which have firstName values…  And regardless of the number of matches which it ought to be generating it returns exactly one result each time.

The array is built up as a side effect of -[NSArray indexOfObjectPassingTest:]. The block that implements the test returns YES when the firstName matches.

Reflect that a method that searches for the index (singular) of a member of an array will stop searching when it finds the object. (Why is it always in the last place you look?) That is, it stops as soon as you return YES, upon the first match.

Your example doesn't use the index indexOfObjectPassingTest: returns. Why do you not want to use -enumerateObjectsUsinghBlock:?

Or, you could use index_es_OfObject_s_PassingTest: and objectsAtIndexes:.

>  (And btw, is it legit to NSLog() from inside a block ?)

Yes.

	— F


_______________________________________________

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: 
 >Searching array with block (From: Erik Stainsby <email@hidden>)

  • Prev by Date: Re: Searching array with block
  • Next by Date: Re: Core Data fetch performance
  • Previous by thread: Re: Searching array with block
  • Next by thread: Adding UINavBar to split view detail in storyboard?
  • Index(es):
    • Date
    • Thread