Hi guys,
I'm catching up with modern Objective-C and found this document:
Adopting Modern Objective-C
and it is talking about using instance type but I'm a bit confused.
On one line it says:
Then in another line it says:
So my question is is id never used anymore? Can anyone give a simple explanation of where to use it and where not to use it?
I'm catching up with modern Objective-C and found this document:
Adopting Modern Objective-C
and it is talking about using instance type but I'm a bit confused.
On one line it says:
Use the instancetype keyword as the return type of methods that return an instance of the class they are called on (or a subclass of that class). These methods include alloc, init, and class factory methods.
Then in another line it says:
In your code, replace occurrences of id as a return value with instancetype where appropriate. This is typically the case for init methods and class factory methods. Even though the compiler automatically converts methods that begin with “alloc,” “init,” or “new” and have a return type of id to return instancetype, it doesn’t convert other methods. Objective-C convention is to write instancetype explicitly for all methods.
So my question is is id never used anymore? Can anyone give a simple explanation of where to use it and where not to use it?