objective c - Batch process an NSArray -


in php use array_chunk split array process each chunk. in objective c doesn't seem straight forward, there cleaner way this?

- (void)processtransaction:(nsarray *)transactions {     nsinteger batchcount = (transactions.count - 1) / self.batchsize + 1;      (nsinteger batch = 0; batch < batchcount; batch ++) {         (nsinteger batchindex = 0; batchindex < self.batchsize; batchindex++) {             nsinteger index = batch * self.batchsize + batchindex;             if (index >= transactions.count) {                 return;             }             transaction *transaction = [transactions objectatindex:index];              // process         }         // save     }     // done } 

if // save isn't complicated do

- (void)processtransaction:(nsarray *)transactions {     nsinteger batchindex = 0;     (transaction *transaction in transactions) {         // process         batchindex++;         if (batchindex >= self.batchsize) {             // save             batchindex = 0;         }     }     if (batchindex > 0) {         // save     }     // done }