这是我的回应
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);这里第一响应图像来的数据,第二响应图像没有data.Then如何写的中频条件。
发布于 2016-09-29 12:52:05
基于url,您必须这样做:
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
}
}
}就这样干杯
发布于 2016-09-29 11:09:06
NSNumber * isSuccessNumber = (NSNumber *)[abc4 valueForKey:@"image"];
if([isSuccessNumber boolValue] == YES)
{
NSLog(@"Image is available");
} else {
NSLog(@"Image is not available");
}你的反应是这样的
第一条件:
NSDictionary *r1 = @{@"bool" : @(1)};
NSNumber * isSuccessNumber = (NSNumber *)[r1 valueForKey:@"bool"];
if([isSuccessNumber boolValue] == YES)
{
NSLog(@"Image is available");
} else {
NSLog(@"Image is not available");
}Output1
图像可用
第二条件:
NSDictionary *r1 = @{@"bool" : @(0)};
NSNumber * isSuccessNumber = (NSNumber *)[r1 valueForKey:@"bool"];
if([isSuccessNumber boolValue] == YES)
{
NSLog(@"Image is available");
} else {
NSLog(@"Image is not available");
}Output2
图像不可用
发布于 2016-09-29 11:08:29
您存储的是Dictionary在Array中。
//Here index is an integer value, showing the index of an array responseArray.
if[responseArray[index][@"image"] intValue]!=0){
//Load image
}else{
//Do not load image
}https://stackoverflow.com/questions/39768348
复制相似问题