JSONKit.m:680:12: Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()
JSONKit.m:931:17: Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()
I researched this. Seems isa holds the class for the object. The warnings can be eliminated by replacing the offending lines with:
object_setClass(dictionary, _JKDictionaryClass); // Dictionary case
object_setClass(array, _JKArrayClass); // Array case
Haven't tested this yet, but I did verify that the changes eliminate the warnings in Xcode 4.6 DP2.
A fix is to probably to use something like this:
how is silencing warnings 'ever' a fix... that setClass call looks cool.
It's how johnezang did it.
where? its not in the trunk.
I have the object_setClass fix in production. I haven't measured the performance impact, but saw the notes below in the comments of JSONKit.m, which makes me believe that the change will hurt performance. For my application it's good enough.
// Why not just use object_getClass()? Because object->isa reduces to (typically) a single instruction. Calling object_getClass() requires
// that the compiler potentially spill registers, establish a function call frame / environment, and finally execute a "jump subroutine" instruction.
// Then, the called subroutine must spend half a dozen instructions in its prolog, however many instructions doing whatever it does, then half a dozen
// instructions in its prolog. One instruction compared to dozens, maybe a hundred instructions.
// Yes, that's one to two orders of magnitude difference. Which is compelling in its own right. When going for performance, you're often happy with
// gains in the two to three percent range.
+1 for the above pull ..
+1 for pull req #121
Can please someone explain me if i could still use JSONKit after Xcode auto-fix?
dictionary->isa = _JKDictionaryClass -------> object_setClass(dictionary, _JKDictionaryClass);
Should do. I've not seen any breakages after applying the fix.