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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category