1

I am taking a class (computer based training on Lynda.com) and the instructor goes on and on about using "release" for your objects. This course was created in 2011 and clearly Apple has updated their product to do the release for you automatically. While I know I can go back to a manual mode and release items myself (eg turn off ARC), my question is this: what is the best practice? Should I leave ARC on or turn it off? Perhaps you have a good example as to when I should make this choice?

Also, if I am totally off base on this, your help is appreciated as well :-)

Thanks.

Hemang
  • 26,840
  • 19
  • 119
  • 186
Bill
  • 582
  • 1
  • 7
  • 21
  • 3
    I have yet to see a crash that was caused by using ARC, but I've seen my own apps crash hundreds of times because of premature release, so I vote for ARC. ;-P – Matthias Bauch Jul 09 '13 at 02:14

2 Answers2

5

There is no reason to start a new project today that does not use ARC.

However, learning how to do memory management through retain/release may be useful if you are hoping to work as an iOS developer on existing projects, since in many older codebases memory management is still done manually.

Cezar
  • 55,636
  • 19
  • 86
  • 87
3

What is the best practice? Should I leave ARC on or turn it off?

Best practice is using ARC for all new development, and selectively turning ARC off only for legacy libraries.

Perhaps you have a good example as to when I should make this choice?

The choice is very simple: if you are maintaining a large body of code with manual memory management, turn ARC off; otherwise, keep ARC on.

It is still very beneficial to get a working knowledge on how retain/release work: it would let you understand ARC at a deeper level.

As a side note, consider switching the course to something that has been updated in the last two years: ARC is easily the most important change in the language that has been introduced in the last few years; you definitely do not want to miss out on it.

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523