Expression result unused warning in for loop
cocoa, cocoa-touch, objective-c
Solution
Since you declared `i` outside the loop, the expression `i` in the first part of the `for` is unused:
for ( i /* <<== This one */ ; i < tags.count; i ++) {
}
The syntax of the `for` loop lets you drop the content of any of its three expression compartments. This should fix the problem:
for ( ; i < tags.count; i ++) {
}
In fact, you can drop all three, making the loop infinite:
for ( ; ; ) {
...
if (some_condition) break;
...
}
Note: in general, you should declare loop variables as part of the loop header. The only exception is when you need to use the final value of `i` outside your loop.
Problem
I am getting "Expression result unused" warning in the following for loop. ``` NSInteger i = 0; for ( i; i < tags.count; i ++) { } ``` Seems like I am missing some basic knowledge on how the for loops works , Can anyone shed some light on reason for this warning ?