-
问题描述:无法对逻辑值做出正确判断
在服务器端
boolean isSuccess = false;
客户端接收到json数据,转化为字典类型输出,正确时为1,错误时未零。
if ([responseDic objectForKey:@"isSuccess"] ) {
[SVProgressHUD showSuccessWithStatus:@"Succeed !"];
} else{
[SVProgressHUD showErrorWithStatus:[responseDic objectForKey:@"errorInfo"]];
}
无论服务器返回对错,if判断都为正确
- 解决方案:
BOOL isSuccess = [[responseDic objectForKey:@"isSuccess"] boolValue];
if (isSuccess) {
[SVProgressHUD showSuccessWithStatus:@"Succeed !"];
} else{
[SVProgressHUD showErrorWithStatus:[responseDic objectForKey:@"errorInfo"]];
}
- PS:此方法同样适用于其他数据类型