ios - counter inside enumerateObjectsUsingBlock -
i need iterate through nsarray calculate metrics (total height). here's code:
__block cgfloat height = someinitialvalue; [messages enumerateobjectsusingblock:^(id obj, nsuinteger idx, bool *stop) { if (condition1) height += somevalue; if (condition2) height += somevalue; }]; each iteration starts height = someinitialvalue. want continually increase height. possible calculate total height block-enumeration or have use fast enumeration?
you increasing height in code here. height marked __block identifier means can set within block.
the nsuinteger idx block parameter counter loop (in case need that).
there seems no reason use block enumeration in case.
Comments
Post a Comment