当我从JSON
php 获取值时,我遇到了以下问题__NSCFBoolean isEqualToString
:
我的代码如下:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
//convert to JSON
for(id key in res) {
id value = [res objectForKey:key];
NSString *keyAsString = (NSString *)key;
NSString *valueAsString = (NSString *)value;
//NSCFBoolean
/*if([value isKindOfClass:[NSNumber class]])
{
printf("Number");
}
else if([value isKindOfClass:[NSString class]])
{
printf("String --- \n");
if([value isEqualToString:@"0"])
{
printf("Wrong \n");
}
else
{
printf("Right \n");
}
}*/
NSLog(@"%@",[valueAsString class]);
if([keyAsString isEqualToString:@"success"])
{
printf("Working \n");
}
else
{
printf("Not Working\n");
}
//Error is in below line
if([valueAsString isEqualToString:@"0"])// strcmp([value objCType], @encode(BOOL)) == 1)
{
[self loginSuccess];
}
else if(strcmp([value objCType], @encode(BOOL)) == 0)
{
[self loginFailure];
}
NSLog(@"key: %@", keyAsString);
NSLog(@"value: %@", valueAsString);
}
} }
获取[__NSCFBoolean isEqualToString:]:
发送到实例 0x1dc9964 的无法识别选择器的问题
从昨天开始在谷歌搜索这个问题,但还没有解决方案。现在,NSCFBoolean 在 iOS 6.0 中也不可用。那么我该怎么做才能从JSON
字符串中检查“0”或“1”呢?请帮忙。