Differences between for-in, for and enumerateobjectsusingblock traversal

Source: Internet
Author: User

1. In cases where the number of objects in the collection is large, the for-in traversal is very fast, but small-scale traversal is not obvious (not yet normal for-loop fast)

2. If the array has been modified in the for In loop, either by adding, deleting, modifying the position of the array element, an exception is thrown, and the array has mutated during enumeration (<__NSArrayM:0xa4fc000> was mutated while Being enumerated.), but the enumerator can be detected.

3.Value Query Index, the face of a large number of arrays recommended enumerateObjectsWithOptions for the use of parallel methods.

4. When traversing the dictionary type, it is recommended to use the enumerateKeysAndObjectsUsingBlock block version of the dictionary traversal can take both key and value (Forin can only take the key and then manually fetch value)



Differences between for-in, for and enumerateobjectsusingblock traversal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.