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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -