Are id and instancetype same? If not, what are differences between them?
Answer / Lakhan Singh
In Objective-C, `id` is a generic type that can represent any object, while `instancetype` is a specific type defined by the class being initialized. The main difference is that `id` can represent any object, including objects of unknown or unrelated classes, whereas `instancetype` is always the same as the class being initialized. For example, if you create an instance of a custom class using `[[MyClass alloc] init]`, the return type is `MyClass *`, which is the same as `MyClass instancetype`. However, if you assign an instance of another class to an `id` variable, it will still be accepted but may result in runtime errors.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the class of a constant string?
What is the latest version of objective-c?
What is toll-free bridging? When is it useful?
What is the primary use of the category in the objective-c?
What is the difference between property and instance variable?
What is nsmutabledictionary?
What is the major difference between objective c and swift?
What is objective c programming used for?
What is a category in objective c?
What is thread safe function?
What is parsing? Mention which class can you use for parsing of xml in iphone?
What is difference between null and nil?