Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 : 'isa' is deprecated

I get warning when I run my app in iOS7 "'isa' is deprecated", I don't have any idea how to fix this warning message. Please any one help on this.

array->isa      = _JKArrayClass;
like image 899
Divya Bhaloidiya Avatar asked Nov 09 '13 11:11

Divya Bhaloidiya


2 Answers

Include <objc/runtime.h>.

Replace everything like array->isa = _JKArrayClass; with object_setClass(array, _JKArrayClass)

And everything like class = array.isa with class = object_getClass(array)

like image 158
Sviatoslav Yakymiv Avatar answered Oct 24 '22 05:10

Sviatoslav Yakymiv


I figured I would share my solution for you Cocoapods users out there. (Please let me know in the comments if you have found a better solution)

I am using Cocoapods and for this reason I do not want to modify the source code of the libraries I am pulling in. The problem is caused by Cocoapods setting the "Direct usage of 'isa'" value to "Yes (treat as error)", thus causing all automated builds to fail.

I have fixed the problem by adding this to my Podfile:

post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CLANG_WARN_DIRECT_OBJC_ISA_USAGE'] = 'YES'
        end
    end
end

This way the direct usage of 'isa' will show up as warning but will not cause automated builds to fail.

But in arm64 iOS Device build(with Xcode 5.1.0) strangely CLANG_WARN_DIRECT_OBJC_ISA_USAGE = 'YES' option will not properly applied(treat as error). If you need to build, including arm64 just CLANG_WARN_DIRECT_OBJC_ISA_USAGE = 'NO' option can be used.

like image 22
bsarrazin Avatar answered Oct 24 '22 03:10

bsarrazin