I am having this simple code and I really cannot say what is happening:
NSLog(@"Data: %@",[dataFromServer description]);
for (int i=0; i<[data count]; i++) {
NSLog(@"Processing data :%d",i);
NSDictionary *current=[data objectAtIndex:i];
int category = [[current objectForKey:@"type"] intValue];
NSLog(@"Category value:%d",category);
if (category == 1) {
NSLog(@"Hotel found %@",[current description]);
[hotelsFromServer addObject:current];
}
NSLog(@"Hotels. Total:%d Items:%@",[hotelsFromServer count],[hotelsFromServer description]);
I am fetching an NSMutableArray from my server (dataFromServer) which is printed correctly. Each object is an NSDictionary. Category 1 means that the type is a hotel. I enter the if clause, and hotel is being printed correctly.
But outside the for, for the final NSLog, I get these:
Hotels. Total:0 Items:(null)
Why is that? The current item is correct. Why it is not added into my NSMutableArray.
Array is defined like this:
@implementation ClassName
{
NSMutableArray * dataFromServer;
NSMutableArray * hotelsFromServer;
}