我有一本声明的字典,像这样,
NSString *responseString = [request responseString];
responseDict = [responseString JSONValue];
for (id key in responseDict){
NSLog(@"%@ : %@", key, [responseDict objectForKey:key]);
}
结果 :
013-01-22 00:14:02.323 PromoTest[2352:c07] A : 0
2013-01-22 00:14:02.325 PromoTest[2352:c07] B : 1
2013-01-22 00:14:02.325 PromoTest[2352:c07] C : 0
现在,我想比较该值并对其进行一些操作。我假设键的值是 NSString 类型,并将其与我的常量 NSString 进行比较,如下所示,
NSString *myString1 = @"0";
NSString *myString2 = [responseDict objectForKey:@"A"];
NSLog(@"%d", (myString1 == myString2)); //1
NSLog(@"%d", [myString1 isEqualToString:myString2]); //1
结果:
2013-01-22 00:19:12.966 PromoTest[2423:c07] 0
2013-01-22 00:19:12.966 PromoTest[2423:c07] 0
我哪里错了??我的比较有错吗?如何正确比较内容?
数据作为响应数据从 Web 服务接收。我只是将数据转换成字典以便于使用它。Web 服务返回一个 JSON 对象,
{"A":0,"B":1,"C":0}