1. ID and NSObject * (1) ID are objective-c objects, but not necessarily nsobject objects, not all Foundation/cocoa objects are inherited from NSObject objects, such as Nsproxy. At the same time, there are a lot of common methods between ID and NSObject object, such as retain and release method. In one step: All objects are essentially ID types. (2) for ID, you can call any visible selector, the compiler and IDE do not do type checking, this time you need to do type check and type conversion, to ensure that these calls do not go wrong. For NSObject * types, only the selector declared by the NSObject object can be called, and the selector of its subclasses cannot be called, and the compiler checks. (3) You can use the ID for some places where you do not want to or cannot do a type check. For example, in a collection (array, collection) type, such as in some places where you do not know the return type of the method (such as Alloc), for example, we often declare delegate as the ID type, and then use Respondtoselector when running: To check it out. 2. Id<nsobject> uses id<nsobject> to declare an object, which is equivalent to telling the compiler that we don't know the type of the object, but it implements NSObject protocol. A pointer of this type, which can be used to point to a nsobject* object or to a Nsproxy* object, because the NSObject object and the Nsproxy object are now NSObject protocol. 3. ID and Instancetype in the case of instancetype effective, should try to use Instancetype. As for what is appropriate, refer to stack overflow above: "Use instancetype whenever it's appropriate, which is whenever a class returns an Instan Ce of that same class. ", http://stackoverflow.com/questions/8972221/ would-it-be-beneficial-to-begin-using-instancetype-instead-of-id/14652187#14652187
ID, NSObject *, id<nsobject>, instancetype differences