Siva Sankar Siva Sankar - 2 months ago 8
iOS Question

How to write the condition for BOOL values

this is my response

1.{

image = nbYijSxVXDOFGWFk8BhZUpU
"is_food_in_time_product" = 1;
"list_price" = "2.8";
name = Export;

}
2.
{

image = 0;
"is_food_in_time_product" = 1;
"list_price" = 1;
name = "K\U00e4se";

}

NSString *abc5 = [abc4 valueForKey:@"image"];
NSLog(@"%@",abc5);


Here first response image coming data, second response image no data.Then How to write the if condition.

Answer

Based on url you have to do like this:

            NSDictionary *responseDataDictionary = responseObject;
//here responce object is your total data which is coming from server
            NSArray *array = [[responseDataDictionary valueForKey:@"result"] valueForKey:@"products"];
            for (NSDictionary *dict in array)
            {
                NSString *str = [dict valueForKey:@"image"];
                if([str isKindOfClass:[NSString class]])
                {
                    NSLog(@"YES");
//here you have to add your image as usual to another mutable array
                }else{
                    NSLog(@"NO");
// bool value happens means this will execute
// Here you have to add custom image ie.placeholder image
                }

            }
        }

that's it cheers