in Technology by (1.8m points)
Are id and instanceType same? If not, what are differences between them in Objective-C?

1 Answer

0 votes
by (1.8m points)

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.

Related questions

0 votes
asked Mar 31 in Education by JackTerrance (1.8m points)