Method Names and Non-ARC Compiled Code

ARC works with code that has not been compiled with ARC. This can happen if you’re linking with an older framework, for example. As long as the non-ARC code has conformed to the standard Cocoa naming conventions, all will be okay. That is, when ARC sees a method call, it checks the method’s name. If the name begins with the words alloc, new, copy, mutableCopy, or init, it assumes that the method returns ownership of the object back to the method caller.

When we talk about “words” here, we refer to the words being written in what’s known as camelCase. That’s where the first letter of each new word in the name begins with a capital letter. So, the compiler assumes methods named allocFraction, newAddressCard ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.