代码
NSString *nodeType = [subNodeDict objectForKey:@"nodeType"];
NSLog (@"nodeType = %@", nodeType);
NSLog (@"(nodeType == @\"Collection\") = %d", nodeType == @"Collection");
NSLog (@"[nodeType class] = %@ and [@\"Collection\" class] = %@", [nodeType class], [@"Collection" class]);
日志
2013-01-01 04:06:37.895 GoogleClient[4752:c07] <strong>nodeType = Collection
2013-01-01 04:06:37.896 GoogleClient[4752:c07] <strong>(nodeType == @"Collection") = 0
2013-01-01 04:06:37.896 GoogleClient[4752:c07]
<strong>[nodeType class] = __NSCFString and [@"Collection" class] = __NSCFConstantString
subNodeDict
是通过 AFNetworking 从服务器返回的 JSON 响应对象。
我不知道如何准确地将从服务器返回的字符串与常量字符串进行比较。subNodeDict 中的所有非字符串对象都可以正常工作。我需要使用某种类型的 UTF-8 编码吗?我怎样才能得到真正的价值节点类型?