The JKDictionary class is private to JSONKit and should not be used in this fashion

天大地大妈咪最大 提交于 2019-12-11 05:05:56

问题


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

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);
}

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.

Any kind of help would be appreciated.


回答1:


I ended up replacing the problematic line with this self.responseJSON = [[CJSONDeserializer deserializer] deserialize:self.responseData error:&error];

Used a different class (TouchJSON) just for that line but it works great now.



来源:https://stackoverflow.com/questions/14118166/the-jkdictionary-class-is-private-to-jsonkit-and-should-not-be-used-in-this-fash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!