i have a nested nested (double nested) if statement inside a method which is called several times. each time i add one to the int (count) inside that if statement. here it is:
if (currentString) {
count += 1;
NSLog(@"%i" , count);
}
I logged it and it logged few times but the number was ALWAYS 1:
2012-01-27 12:29:26.127 Appletini[479:10a03] 1
2012-01-27 12:29:26.128 Appletini[479:10a03] 1
2012-01-27 12:29:26.132 Appletini[479:10a03] 1
2012-01-27 12:29:26.134 Appletini[479:10a03] 1
2012-01-27 12:29:26.138 Appletini[479:10a03] 1
2012-01-27 12:29:26.139 Appletini[479:10a03] 1
2012-01-27 12:29:26.143 Appletini[479:10a03] 1
2012-01-27 12:29:26.143 Appletini[479:10a03] 1
count is an instance variable:
@interface RSSItem : NSObject <NSXMLParserDelegate> {
int count;
}
any ideas???
My guess is that you meant to make “count” be
staticso it retains its value, but you forgot so it is just a normal local variable.