ios - Call same method multiple times on different parts of array -


i have method can work array of maximum 100 objets.

however have array more 100 objects, how call method multiple times work arrays have more 100 objets?

let's have array of 264 objects.

i call method 3 times so:

[self dosomething:[arraywithmorethan100objects subarraywithrange:nsmakerange(0, 100)]; [self dosomething:[arraywithmorethan100objects subarraywithrange:nsmakerange(100, 100)]; [self dosomething:[arraywithmorethan100objects subarraywithrange:nsmakerange(200, 64)]; 

this works fine, don't know size of array method needs process calling manually wont work.

how around this?

thanks!

use loop:

nsinteger increment = 100; (nsinteger start = 0; start < arraywithmorethan100objects.count; start += increment) {     nsinteger length = min(increment, arraywithmorethan100objects.count - start);     nsrange range = nsmakerange(start, length);     [self dosomething:[arraywithmorethan100objects subarraywithrange:range]; } 

the value of length set either 100 or smaller value if there less 100 objects left in array.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -