I have experience with pure ARC coding. As a compiler feature it honors Objctive-C method family putting right retain/release calls whenever neeeded.
All methods that start with alloc
, mutableCopy
, copy
and new
create a new object. They increase the retain count. As a consequence, ARC will release any pointer (and hence the object associated with it) when I no longer need it.
I think that problems could arise when I write methods that do not follow naming conventions. For example, if I write a method like newCustomer
that in a first version returns an autoreleased object while in a second version does not, what could happen?
In particular, my questions are the following (they belong to the same reasoning):
- What happens if the calling and called code are both compiled with ARC?
- (a) What happens if the calling code is compiled with ARC while the called is compiled with non-ARC?
- (b) What happens if the calling code is compiled with non-ARC while the called is compiled with ARC?
It would be appreciated an answer that shows how ARC works under the hood (objc_release
, objc_retainAutoreleasedReturnValue
, etc.).
Thank you in advance.