KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Recent Objective-C compilers introduce the 'instancetype' keyword, which among other things can be used to provide typed collections. . . I saw another purpose of instancetype, which was using it in 'objectWith' type methods on classes. For example: @interface Car +(instancetype)carWithWheels:(NSArray*)wheels; @end The justification was that the compiler will do type checking for initWith methods, but not for 'objectWith' methods. Besides being potentially easier to type, what is the benefit of using 'instancetype' in place of the actual class-name? Eg: @interface Car +(Car*)carWithWheels:(NSArray*)wheels; @end
Tags (comma-separated)
Save Edits
Cancel