johnezang / JSONKit

Objective-C JSON
6.21k stars 1.66k forks source link

Xcode 7 Before is use JSONKit in Object but now not use JSONKit in Xcode 7 #185

Open BadSuNian opened 9 years ago

BadSuNian commented 9 years ago
        NSArray * josnArry = [[NSArray alloc] init];            
        NSString * josnString = [josnArry JSONString];

Xcode 7 reported the wrong how to solve the crash

Gareth-swifter commented 9 years ago

https://github.com/jcbertin/JSONKit

use it

BadSuNian commented 9 years ago

I've replaced the still crash tip:

Sep 19 14:18:35 XXXX[718] : CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. Sep 19 14:18:35 XXXX[718] : CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. Sep 19 14:18:35 XXXX[718] : CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

caisd1998 commented 8 years ago

@BadSuNian I have same problem. I thought it was because of JSONKit, but I still have crash after applied @h532930330's patch. And then I find out that another third party library TXJSONKitSerializing defines same category method which crashes app. How I fix: I changed JSONKit's category method name to another to avoid using TXJSONKitSerializing because TXJSONKitSerializing is inside some lib.a so I can't change. Chinese comment (中文解释) 我根据上面的comment解决后,还是有问题,后来发现,在运行的时候,方法JSONString其实是调用了某个第三方库的TXJSONKitSerializing定义的方法,而不是JSONKit里的。 看样子,在运行时,第三方库的方法覆盖了源码里的同样的方法。 解决办法就是,把JSONKit里的方法加个前缀,然后代码里面使用这个加了前缀的方法,这样就不会误用到TXJSONKitSerializing里的。 这也强调了一个写Category方法的要求,尤其是提供给别人使用的第三方库的时候,一定要加上前缀,以防影响到使用者。

poorbird commented 8 years ago

@caisd1998 cool,you are right. 多亏遇到你,找了好几天终于解决了,感谢分享

BadSuNian commented 8 years ago

@caisd1998 my email 97282073@q.com your? Please explain in detail.

loveNoodles commented 8 years ago

My project crashed here :

void _objectISA = (JK_EXPECTF(workAroundMacOSXABIBreakingBug)) ? NULL : ((void )objectPtr);

my codes are like this below: NSArray * josnArry = [[NSArray alloc] init];
NSString * josnString = [josnArry JSONString];

inside josnArry are NSDictionary(s) ! help !

cocoZ commented 8 years ago

Im used "JSONKit" MAJK ?????????????? whats this?