Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable/ disable "Automatic Reference Counting"?

Using Xcode 4.2, how can one enable/disable "Automatic Reference Counting"?

ANSWERED Under Build Settings, flip "yes" and "no" depending whether you want ARC enabled.

enter image description here

like image 992
James Raitsev Avatar asked Oct 15 '11 14:10

James Raitsev


People also ask

What is reference counting in Swift?

Swift uses Automatic Reference Counting (ARC) to track and manage your app's memory usage. In most cases, this means that memory management “just works” in Swift, and you don't need to think about memory management yourself.

Why is automatic reference counting a type of garbage collection mechanism?

Automatic Reference counting or ARC, is a form of garbage collection in which objects are deallocated once there are no more references to them, i.e. no other variable refers to the object in particular.


2 Answers

Globally:

Go to "Build Settings", look for "Apple LLVM compiler 3.0 - Language". Set the field "Objective-C Automatic Reference Counting" to "No".

enter image description here

For individual files:

Go to "Build Phases", select the file, double-click the "Compiler Flags" column and put "-fno-objc-arc" in it.

like image 199
cli_hlt Avatar answered Sep 23 '22 17:09

cli_hlt


To enable ARC per-file, you can also set your "Compiler Flags" under "Build Phases" to -fobjc-arc. Make sure your compiler is set to Apple LLVM compiler 4.x and not LLVM GCC 4.2.

like image 34
Kishyr Ramdial Avatar answered Sep 20 '22 17:09

Kishyr Ramdial