我从服务器收到这些数据 - :
2014-06-04 13:58:40.201 myRequest[2349:11303] parsing JSON: {
"is_vip" = 1;
"my_balance" = "1000.21";
"my_name" = "my_foo";
"my_num" = 100;
}
所有价值都打印得很好。
但是当我在我的模拟器上打印字符串值时,我收到了这个错误。
2014-06-04 13:58:51.967 myRequest[2349:11303] -[__NSCFString stringValue]: unrecognized selector sent to instance 0x8965530
2014-06-04 13:58:51.967 myRequest[2349:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString stringValue]: unrecognized selector sent to instance 0x8965530'
*** First throw call stack:
(0x1c8f012 0x10cce7e 0x1d1a4bd 0x1c7ebbc 0x1c7e94e 0x3914 0xbd05c8 0xb3802a 0xb05d23 0xb05a34 0xb92301 0x49ed53f 0x49ff014 0x49ef7d5 0x1c35af5 0x1c34f44 0x1c34e1b 0x1be97e3 0x1be9668 0x1465c 0x295d 0x2885)
libc++abi.dylib: terminate called throwing an exception
(lldb)
在XCODE中打印代码 - :
NSLog(@"checking Apache value %@",[[greeting objectForKey:@"is_vip"] stringValue]);
和
self.ram.text = [[greeting objectForKey:@"my_name"] stringValue];
答案 0 :(得分:3)
通过以下方式修改您的NSLOg。
NSLog(@"checking Apache value %@",[[greeting objectForKey:@"is_vip"] boolValue]);
第二行:
self.ram.text = [greeting objectForKey:@"my_name"];