isa is deprecated #79

Closed
trawor opened this Issue May 6, 2012 · 20 comments

Comments

Projects
None yet
@trawor

trawor commented May 6, 2012

I got lots of warning like this: /PATH/JSONKit.m:2602:11: Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()

My Xcode is up to 4.4 DP4

@christo16

This comment has been minimized.

Show comment
Hide comment
@christo16

christo16 May 12, 2012

Same issue here, happened after upgrading.

Same issue here, happened after upgrading.

@shannoga

This comment has been minimized.

Show comment
Hide comment
@shannoga

shannoga May 21, 2012

Same issue on 4.4 DP5

Same issue on 4.4 DP5

@tknizam

This comment has been minimized.

Show comment
Hide comment
@tknizam

tknizam Jun 13, 2012

This can be fixed by replacing

object->isa

with

object_getClass(object)

You will also need to replace

keyObject->isa

with

object_getClass(keyObject)

and

(id)keys[idx]->isa

with

object_getClass((id)keys[idx])

tknizam commented Jun 13, 2012

This can be fixed by replacing

object->isa

with

object_getClass(object)

You will also need to replace

keyObject->isa

with

object_getClass(keyObject)

and

(id)keys[idx]->isa

with

object_getClass((id)keys[idx])
@shannoga

This comment has been minimized.

Show comment
Hide comment
@shannoga

shannoga Jun 14, 2012

Thanks, When trying to replace I noticed this note on the file:

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.

Is it still O.K to change that ?
Thanks

Thanks, When trying to replace I noticed this note on the file:

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.

Is it still O.K to change that ?
Thanks

@tknizam

This comment has been minimized.

Show comment
Hide comment
@tknizam

tknizam Jun 14, 2012

You can still keep using object->isa, but eventually that will be dropped as it is deprecated, unless there's a faster way to do the same thing without using object_getClass(), it is the next best solution for now.

If you still wish to use object->isa, you can suppress the warnings.

tknizam commented Jun 14, 2012

You can still keep using object->isa, but eventually that will be dropped as it is deprecated, unless there's a faster way to do the same thing without using object_getClass(), it is the next best solution for now.

If you still wish to use object->isa, you can suppress the warnings.

@MSch

This comment has been minimized.

Show comment
Hide comment
@MSch

MSch Jun 14, 2012

Regarding the object->isa deprecation, once thing I'm not sure of:

Does isa return the NSNumber for the new NSNumbers that are implemented via tagged pointers? (AFAIK that's the reason isa is deprecated)

MSch commented Jun 14, 2012

Regarding the object->isa deprecation, once thing I'm not sure of:

Does isa return the NSNumber for the new NSNumbers that are implemented via tagged pointers? (AFAIK that's the reason isa is deprecated)

@johnezang johnezang closed this Jun 24, 2012

@ghost ghost assigned johnezang Jun 24, 2012

@drekka

This comment has been minimized.

Show comment
Hide comment
@drekka

drekka Aug 7, 2012

I was researching this issue and found https://gist.github.com/2171491 which suggested to me that object_getClass() is no longer slower that isa.

drekka commented Aug 7, 2012

I was researching this issue and found https://gist.github.com/2171491 which suggested to me that object_getClass() is no longer slower that isa.

@antonysastre

This comment has been minimized.

Show comment
Hide comment
@antonysastre

antonysastre Feb 17, 2013

Still produces a deprecation warning:

array->isa      = _CDVJKArrayClass;

and

dictionary->isa      = _CDVJKDictionaryClass;

Any good solution to this?

Still produces a deprecation warning:

array->isa      = _CDVJKArrayClass;

and

dictionary->isa      = _CDVJKDictionaryClass;

Any good solution to this?

@bynelus

This comment has been minimized.

Show comment
Hide comment
@bynelus

bynelus Feb 19, 2013

Same here!

bynelus commented Feb 19, 2013

Same here!

@themil

This comment has been minimized.

Show comment
Hide comment
@SpacyRicochet

This comment has been minimized.

Show comment
Hide comment
@SpacyRicochet

SpacyRicochet Mar 12, 2013

Those aren't solutions, they just hide away the warnings. Good enough for a quick fix (I'm using it, so thanks), but nothing near a real solution.

Those aren't solutions, they just hide away the warnings. Good enough for a quick fix (I'm using it, so thanks), but nothing near a real solution.

@marcdown

This comment has been minimized.

Show comment
Hide comment
@marcdown

marcdown Apr 1, 2013

Since none of the Pull requests have been accepted I applied the fixes @tknizam suggested as well as used object_setClass(object, Class) to fix @antonysastre's warnings. I also explicitly cast the appropriate format arguments as unsigned long to remove those warnings as well.
Forked repo: https://github.com/creativemess/JSONKit
Podspec: https://gist.github.com/creativemess/5282955/raw/2a52cfd92f112f2a52669420c82c1bb1efd15d2a/JSONKit.podspec

marcdown commented Apr 1, 2013

Since none of the Pull requests have been accepted I applied the fixes @tknizam suggested as well as used object_setClass(object, Class) to fix @antonysastre's warnings. I also explicitly cast the appropriate format arguments as unsigned long to remove those warnings as well.
Forked repo: https://github.com/creativemess/JSONKit
Podspec: https://gist.github.com/creativemess/5282955/raw/2a52cfd92f112f2a52669420c82c1bb1efd15d2a/JSONKit.podspec

@luketheobscure

This comment has been minimized.

Show comment
Hide comment
@luketheobscure

luketheobscure Jun 6, 2013

@CreativeMess How do I reference your podspec?

@CreativeMess How do I reference your podspec?

@marcdown

This comment has been minimized.

Show comment
Hide comment
@marcdown

marcdown Jun 6, 2013

@luketheobscure added the following to your Podfile:

pod 'JSONKit', :podspec => 'https://gist.github.com/creativemess/5282955/raw/2a52cfd92f112f2a52669420c82c1bb1efd15d2a/JSONKit.podspec'

marcdown commented Jun 6, 2013

@luketheobscure added the following to your Podfile:

pod 'JSONKit', :podspec => 'https://gist.github.com/creativemess/5282955/raw/2a52cfd92f112f2a52669420c82c1bb1efd15d2a/JSONKit.podspec'
@jhonyf

This comment has been minimized.

Show comment
Hide comment
@jhonyf

jhonyf Oct 16, 2013

Not sure what happened to @marcdown gist, but recreated it to point to his fork. Use this in your podfile and run pod install

pod 'JSONKit', :podspec => 'https://gist.github.com/jhonyf/7002734/raw/08fd7b28676b97af251b5dd5b375394eedc454f9/gistfile1.rb'

jhonyf commented Oct 16, 2013

Not sure what happened to @marcdown gist, but recreated it to point to his fork. Use this in your podfile and run pod install

pod 'JSONKit', :podspec => 'https://gist.github.com/jhonyf/7002734/raw/08fd7b28676b97af251b5dd5b375394eedc454f9/gistfile1.rb'
@marcdown

This comment has been minimized.

Show comment
Hide comment
@marcdown

marcdown Oct 16, 2013

@jhonyf I updated my handle - here's the updated link:

pod 'JSONKit', :podspec => 'https://gist.github.com/marcdown/5282955/raw/2a52cfd92f112f2a52669420c82c1bb1efd15d2a/JSONKit.podspec'

@jhonyf I updated my handle - here's the updated link:

pod 'JSONKit', :podspec => 'https://gist.github.com/marcdown/5282955/raw/2a52cfd92f112f2a52669420c82c1bb1efd15d2a/JSONKit.podspec'
@PhilTrailerPark

This comment has been minimized.

Show comment
Hide comment
@PhilTrailerPark

PhilTrailerPark Feb 24, 2014

Thanks marcdown. Current JSONKit is still build failing with deprecations but your fork worked great for me. Thanks for saving me doing it by hand. Yeah cocoapods!

Thanks marcdown. Current JSONKit is still build failing with deprecations but your fork worked great for me. Thanks for saving me doing it by hand. Yeah cocoapods!

@xlarsx

This comment has been minimized.

Show comment
Hide comment
@xlarsx

xlarsx May 19, 2014

Thanks for the update!

xlarsx commented May 19, 2014

Thanks for the update!

@ArtSeo ArtSeo referenced this issue in ArtSeo/Multiples Jun 8, 2014

Open

CocoaPods #5

@cesarferreira

This comment has been minimized.

Show comment
Hide comment
@cesarferreira

cesarferreira Jul 1, 2014

@marcdown thanks a lot for that line! :)

@marcdown thanks a lot for that line! :)

@zlc000190

This comment has been minimized.

Show comment
Hide comment
@zlc000190

zlc000190 Jan 22, 2015

i remove the jsonkit

i remove the jsonkit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment