Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3613724
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:09:36+00:00 2026-05-18T22:09:36+00:00

Besides the obvious differences: Use enumerateObjectsUsingBlock when you need both the index and the

  • 0

Besides the obvious differences:

  • Use enumerateObjectsUsingBlock when you need both the index and the object
  • Don’t use enumerateObjectsUsingBlock when you need to modify local variables (I was wrong about this, see bbum’s answer)

Is enumerateObjectsUsingBlock generally considered better or worse when for (id obj in myArray) would also work? What are the advantages/disadvantages (for example is it more or less performant)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:09:37+00:00Added an answer on May 18, 2026 at 10:09 pm

    Ultimately, use whichever pattern you want to use and comes more naturally in the context.

    While for(... in ...) is quite convenient and syntactically brief, enumerateObjectsUsingBlock: has a number of features that may or may not prove interesting:

    • enumerateObjectsUsingBlock: will be as fast or faster than fast enumeration (for(... in ...) uses the NSFastEnumeration support to implement enumeration). Fast enumeration requires translation from an internal representation to the representation for fast enumeration. There is overhead therein. Block-based enumeration allows the collection class to enumerate contents as quickly as the fastest traversal of the native storage format. Likely irrelevant for arrays, but it can be a huge difference for dictionaries.

    • “Don’t use enumerateObjectsUsingBlock when you need to modify local variables” – not true; you can declare your locals as __block and they’ll be writable in the block.

    • enumerateObjectsWithOptions:usingBlock: supports either concurrent or reverse enumeration.

    • with dictionaries, block based enumeration is the only way to retrieve the key and value simultaneously.

    Personally, I use enumerateObjectsUsingBlock: more often than for (... in ...), but – again – personal choice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Besides the syntactic sugar and expressiveness power what are the differences in runtime efficiency.
Which other restrictions are there on names (beside the obvious uniqueness within a scope)?
Besides open-sourcing your project and legislation, are there ways to prevent, or at least
Besides the dynamic nature of Python (and the syntax), what are some of the
Besides the CODEX what resources do you recommend to help a person new to
Besides the DateTime ctor (new DateTime(year, month, day)) , is there any other way
Besides the sample applications featured in the books Beginning Groovy and Grails and The
Besides using script or an iframe, is there any way to get independently operating
1) Besides the negative frequencies, which is the minimum frequency provided by the FFT
Are there other possibilities besides IIS for hosting web sites and web services based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.