JKDictionary类是JSONKit专用的,不应以这种方式使用 [英] The JKDictionary class is private to JSONKit and should not be used in this fashion
问题描述
这是此的后续问题
简而言之,我正在使我的应用程序ios 4.3兼容,并使用支持我的应用程序ios 4的AFNetworking
类版本0.10.1.
这行self.responseJSON = AFJSONDecode(self.responseData, &error);
给了我下面的错误.我对jason并不真正熟悉,并试图弄清楚该错误的含义.
This is a followup question to this
In short, I'm making my app ios 4.3 compatible and using the AFNetworking
class version 0.10.1 that supports ios 4 in my app.
This line self.responseJSON = AFJSONDecode(self.responseData, &error);
gives me the error bellow. I'm not really familiar with jason and trying to figure out what this error means.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** - [JKDictionary allocWithZone:]: The JKDictionary class is private to JSONKit and should not be used in this fashion.'
*** Call stack at first throw:
(
0 CoreFoundation 0x006ef5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018e6313 objc_exception_throw + 44
2 CoreFoundation 0x006a7ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x006a7e6a +[NSException raise:format:] + 58
...
...
26 libdispatch_sim.dylib 0x02888289 _dispatch_call_block_and_release + 16
27 libdispatch_sim.dylib 0x0288acb4 _dispatch_queue_drain + 250
28 libdispatch_sim.dylib 0x0288b2c2 _dispatch_queue_invoke + 49
29 libdispatch_sim.dylib 0x0288b593 _dispatch_worker_thread2 + 261
30 libsystem_c.dylib 0x90093b24 _pthread_wqthread + 346
31 libsystem_c.dylib 0x900956fe start_wqthread + 30
错误来自JSONKit.m:
The error is from JSONKit.m:
+ (id)allocWithZone:(NSZone *)zone
{
#pragma unused(zone)
[NSException raise:NSInvalidArgumentException format:@"*** - [%@ %@]: The %@ class is private to JSONKit and should not be used in this fashion.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSStringFromClass([self class])];
return(NULL);
}
在ios 5中,该应用使用的行self.responseJSON =[NSJSONSerialization JSONObjectWithData:self.responseData options:0 error:&error];
效果很好,但是由于不支持NSJSONSerialization
,所以我不能在ios 4中使用此行.
With ios 5 the app is using the line self.responseJSON =[NSJSONSerialization JSONObjectWithData:self.responseData options:0 error:&error];
that works great but ofcourse I can't use this in ios 4 because NSJSONSerialization
isn't supported.
任何帮助将不胜感激.
推荐答案
我最终用这个self.responseJSON = [[CJSONDeserializer deserializer] deserialize:self.responseData error:&error];
仅针对该行使用了不同的类( TouchJSON ),但现在效果很好.
Used a different class (TouchJSON) just for that line but it works great now.
这篇关于JKDictionary类是JSONKit专用的,不应以这种方式使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!