ReturnsRetained & ReturnsUnretained
ReturnsUnretained aspects can be used to override the default ARC naming conventions for whether methods return a retained or unretained results.
By default, Objective-C has well-defined rules, based on method names, whether objects returned by a method are retained (i.e. owned by the caller and must be released) or unretained (i.e. owned by the callee).
While ARC hides these complexities from the developer, the underlying rules still apply, even if with ARC the developer does not need to worry about the distinction since ARC automatically decides how to handle the life time management of returned objects.
However, there can be corner-cases where a method uses a naming convention that implies one behavior, but the method really follows a different one. These attributes can be used on methods that do not adhere to the ARC naming conventions for the retain count on returned objects to override how the compiler will handle reference counting. For example, a method called
copy is defined by ARC rules to return an object with a +1 retain count; if it were to be marked with
ReturnsUnretained, the compiler would treat it as returning an un-owned object instead.
The ReturnsRetained and ReturnsUnretained aspects are available on the Cocoa platform only.
Defined by the core compiler