Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass() #106

Open
Whirlwind opened this issue Nov 15, 2012 · 11 comments

Comments

@Whirlwind
Copy link

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()
XCODE 4.6DP2

@vchav73
Copy link

vchav73 commented Nov 25, 2012

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.

@Bo98
Copy link

Bo98 commented Dec 5, 2012

A fix is to probably to use something like this:

5663f2d

@Daij-Djan
Copy link

how is silencing warnings 'ever' a fix... that setClass call looks cool.

@Bo98
Copy link

Bo98 commented Jan 11, 2013

It's how johnezang did it.

@Daij-Djan
Copy link

where? its not in the trunk.

@Bo98
Copy link

Bo98 commented Jan 11, 2013

5663f2d

@vchav73
Copy link

vchav73 commented Jan 11, 2013

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.

@davidsielert
Copy link

+1 for the above pull ..

@grichards-trulia
Copy link

+1 for pull req #121

@vakulenkom
Copy link

Can please someone explain me if i could still use JSONKit after Xcode auto-fix?

dictionary->isa = _JKDictionaryClass -------> object_setClass(dictionary, _JKDictionaryClass);

@Bo98
Copy link

Bo98 commented Jul 22, 2013

Should do. I've not seen any breakages after applying the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants