having errors when import class non-Automatic Refe

2019-09-15 05:07发布

问题:

Just create new project and checked Automatic Reference Counting and downloaded another project. when I import the downloaded classes to my project, it gives too much errors, after searching I found that because the downloaded project is non-Automatic Reference Counting .

so, what is the solution for this problem please ?

回答1:

This occurs because calls like "release" cause errors in ARC projects so that you don't use them because the compiler does this for you. To keep ARC enabled on your classes and disable it on the class you've imported go to your build phases and add the compiler flag "-fno-objc-arc" to the class that you want to use manual memory management.



回答2:

Those files need to be flagged to the compiler so the compiler does not use ARC with them. Use the -fno-objc-arc flag. Click on your project file, click on your application's target, click on the "Build Phases" tab, expand on "Compile Sources", and double click on the files without ARC. Once a little window pops up, put the -fno-objc-arc flag on those files.



标签: iphone ios xcode