Question

As a newbie to the iOS, i need to know the main differences between ARC and Non-ARC. Am using X-Code 3.2, so need to know the main feature of ARC that distinguishes against non-ARC ? any help is appreciated. Thank you.

Was it helpful?

Solution

Automatic reference counting (ARC) was introduced in the iOS 5 sdk to free Objective-C programmers from having to handle memory management by making memory management the job of the compiler.

When using ARC there is no need for retain and release calls, and not only that in many cases ARC can provide a significant performance increase.

ARC is a feature of the new LLVM 3.0 compiler and it completely does away with the manual memory management that all iOS developers love to hate.

Using ARC in your own projects is extremely simple. You keep programming as usual, except that you no longer call retain, release and autorelease. That’s basically all there is to it.

My suggestion is to use ARC.

For your reference you can read this:-

http://clang.llvm.org/docs/AutomaticReferenceCounting.html

What are the pros and cons of using the ARC in an iOS project?

An ARC program's execution is nearly identical to well written MRC. That is, the behavioral differences are often undetectable because both the order of operations and performance are very close.

If you already know how to implement OS X or iOS apps with manual reference counting (MRC), ARC doesn't really add functionality -- it just allows you to remove reference counting operations from your sources.

If you don't want to learn MRC, then you may want to first try ARC. A lot of people struggle with, or try to ignore common practices of MRC (example: I've introduced a number of objc devs to the static analyzer). If you want to avoid those issues, ARC will allow you to postpone your understanding; you cannot write nontrivial objc programs without understanding reference counting and object lifetimes and relationships, whether MRC, ARC, or GC. ARC and GC simply remove the implementation from your sources and do the right thing in most cases. With ARC and GC, you will still need to give some guidance.

If the program you're developing has rather loose usage of reference counting (e.g. a typical amount of autoreleases), switching to ARC could really improve your program's execution times and peak memory usage.

OTHER TIPS

The simple answer is that in non-ARC projects you have to control almost all memory operations (ownership, release time and etc.) by yourself. On the other hand, in ARC enabled projects most work done by system. More you can read via links that given in comments. If you are newbie then probably you should omit non-ARC projects by now and return later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top