0 votes
in Technology by (323k points)
Are id and instanceType same? If not, what are differences between them in Objective-C?

1 Answer

0 votes
by (323k 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.