objective-c - enumerateObjectsUsingBlock in NSArray: What it mainly does.
仅有的幸福
仅有的幸福 2017-05-16 13:18:34
0
2
872

In the process of looking at the source code, I saw that some methods used

enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop);

Then I did some operations in this method. Add the value to the array. What is the benefit of writing this way? What is its specific effect? ​​What is the difference between it and the for loop and the for in loop?

仅有的幸福
仅有的幸福

reply all(2)
为情所困

Array query, the efficiency advantage of small query is not very obvious, it is recommended to use forin. But for a large number of arrays, it is recommended to use enumerations

Another one is to traverse the dictionary and it is recommended to use enumerations, so that you can get the key and value at one time

小葫芦

You can operate on the array when traversing the array.
If you use forin, it is easy to crash when operating on the array when traversing the array

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template