2
votes

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:)

2
@janusfidel Thanks for those, but it maybe not the answer I want.Henry

2 Answers

4
votes

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.

0
votes

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?