Using instancetype
as a return value of init
and related methods is the recommended way to proceed, see the latest clang features. However, what is the best practice w.r.t. the return value of copyWithZone:
in the NSCopying
protocol (see this thread for previous best practices)? It is not mentioned in the rules for inferring the class from the naming scheme of the methods in the clang article, but I don't see why it should be different than the return value of the alloc
method.
Does the type inference not work for copy
-methods? Should we still return instancetype
or rather the specific class type we actually return?