How to Remove ARC in iPhone

Introduction

ARC stands for Automated Reference Counting. Objective-C does not have a garbage collector; instead it uses the reference counting algorithm to manage the memory. This was the developer's task until Apple launched iOS 5.0. Again if you are targeting iOS 4.0 or earlier, ARC is not available to you.

ARC is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects. Instead of you having to remember when to retain or release an object, ARC evaluates the lifetime requirements of your objects and automatically inserts the appropriate method calls at compile time.

Reference Counting: In this algorithm every object keeps track of it owners (in other words reference variables from the program) . The number of owners is represented by the property retainCount declared in NSObject. If this retainCount goes to "0" the object is deallocated automatically. We never call a dealloc method on any object explicitly.

When we use old code in a new project and set the ARC option to enabled, then it shows an error. To remove it we use the following procedure.


Step 1

ARC-in-iPhone.png

Here we set the checkbox to enable ARC.

Step 2

Error-in-Xcode.png

Here we see many errors due to ARC.

Step 3

Click-on-project-in-iPhone.png

Now we click on project.

Step 4

Compile-source-in-iPhone.png

Select Build Phase and click on Compile Source.

Step 5

Click-on-Compile-flag-in-iPhone.png

Here in Compile Source it shows 18 items.

Step 6

write-on-compile-flag-in-iPhone.png

In each step we click on the Compiler Flag and write on it  -fno-objc-arc.

Step 7

Now we run our project; it doesn't show an error and works properly. 


Similar Articles