JSONKit崩溃:在iPad的ratina 64位设备模拟器iOS7 X $ C $Ç5.1 [英] JSONKit Crash: iOS7 Xcode 5.1 in iPad ratina 64 bit device simulator
问题描述
我已经使用 JSONKit 库来解析字典,并获得 JSON
字符串。一切都很好,好正常的设备(iOS7)。但是,当我运行的应用程序在iOS的7-64位模拟器它坠毁在下面的方法:
I have used JSONKit library to parse dictionary and get JSON
string. All is well and good with normal devices (iOS7). But when i run application in iOS 7-64 bit simulator it was crashed at below method:
- (NSString *)JSONString;
和在这条线的崩溃消息显示 JSONKit.m
类
And the crash message shows on this line of JSONKit.m
class
试图找出它,但无法理清。
Tried to find out it but not able to sort out.
和我结束了我们本土的 NSJSONSerialization 类。
And i ended up with our native NSJSONSerialization class.
难道任何一个理清这一点?
Did any one sort out this?
推荐答案
据我所知,有不止一个的补丁版本试图修复64位的崩溃问题,你提到这里,如通过heroims JSONKit 64位崩溃修复。
As far as I know there are more than one patch versions that tried to fix the 64 bit crash issue you mention here, e.g. JSONKit 64bit crash fix by heroims.
他们都试图解决这个棘手线获得的标记指针的第一件事,一个指向一个Objective-C的对象点是一个指向对象类:
They all tried to fix that troublesome line for getting tagged pointers, "the very first thing that a pointer to an Objective-C object "points to" is a pointer to that objects class":
*((void **)objectPtr)
我写了一个简单的code,以模拟碰撞,
I wrote a simple code to emulate the crash,
NSDictionary *dic = @{@"hi":@(4)};
void *keys[2], *objects[2];
CFDictionaryGetKeysAndValues((CFDictionaryRef)dic, (const void **)keys, (const void **)objects);
void *objectPtr = objects[0];
void *another = *((void **)objectPtr);//Only works for 32 bit machine
NSLog(@"%@",[another description]);
我的猜测是,对于64位编译器,苹果改变了标记指针实现的NSNumber,这会导致崩溃。检查此标记指针的讨论<一href="http://stackoverflow.com/questions/5819387/why-is-nsnumber-immutable">stackoverflow.com/questions/5819387/why-is-nsnumber-immutable
如果我修改的NSDictionary * DIC = @ {@喜:@(4)};
到的NSDictionary * DIC = @ {@ 喜:@你好};
它不会崩溃
If I change NSDictionary *dic = @{@"hi":@(4)};
to NSDictionary *dic = @{@"hi":@"hello"};
it won't crash.
我这里所说的补丁只是用object_getClass,这似乎打败的初衷,为什么不直接使用 object_getClass()
?......(评论权以上)
The patch I mentioned here just used object_getClass, which seems to defeat the original purpose, "Why not just use object_getClass()
?..." (the comments right above)
所以,就像你说的,现在我也最终使用NSJSONSerialization类。
So like you said now I also end up using NSJSONSerialization class.
这篇关于JSONKit崩溃:在iPad的ratina 64位设备模拟器iOS7 X $ C $Ç5.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!