Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Are id and instancetype same? If not, what are differences between them?



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

Post New Answer

More Objective-C Interview Questions

What is the class of a constant string?

1 Answers  


What is the latest version of objective-c?

1 Answers  


What is toll-free bridging? When is it useful?

1 Answers  


What is the primary use of the category in the objective-c?

1 Answers  


What is the difference between property and instance variable?

1 Answers  


What is nsmutabledictionary?

1 Answers  


What is the major difference between objective c and swift?

1 Answers  


What is objective c programming used for?

1 Answers  


What is a category in objective c?

1 Answers  


What is thread safe function?

1 Answers  


What is parsing? Mention which class can you use for parsing of xml in iphone?

1 Answers  


What is difference between null and nil?

1 Answers  


Categories