As LLVM compiler with ARC option add retain, copy,release and autorelease for us automatically, but how does ARC determine whether to use retain or copy? Thanks in advance:)

- 55,009
- 24
- 135
- 201

- 481
- 4
- 17
-
might help http://stackoverflow.com/questions/6260256/what-kind-of-leaks-does-automatic-reference-counting-in-objective-c-not-prevent/6388601#6388601 http://stackoverflow.com/questions/6385212/how-does-the-new-automatic-reference-counting-mechanism-work – janusfidel Jun 28 '12 at 06:31
-
@janusfidel Thanks for those, but it maybe not the answer I want. – Henry Jun 28 '12 at 06:56
2 Answers
ARC doesn't add copy
, that's still your responsibility if you need copies. It only manages retain
and release
for you. If you manually copy
something though it knows that you get a new object that it will have to release at some time.

- 22,475
- 4
- 52
- 71
As mentioned in following docs (http://clang.llvm.org/docs/AutomaticReferenceCounting.html#meta)
Automatic Reference Counting implements automatic memory management for Objective-C objects and blocks, freeing the programmer from the need to explicitly insert retains and releases. It does not provide a cycle collector; users must explicitly manage the lifetime of their objects, breaking cycles manually or with weak or unsafe references.
Also you can go through the discussion of this thread - How does the new automatic reference counting mechanism work?