什么是id,与void *的区别this
id在Objective C中是一个类型,一个complier所承认的Objective C类型,跟void *是不同的,好比一个 id userName, 和void *pUserName,[userName print] 是能够的,但[pUserName print] 在编译时就会报错,由于ObjeciveC的编译器看到id,会假定它能够接受任何message,虽然在runtime时可能并非这样的,但pUserName并非Objective C类型,编译器就会报错,可是void *有可能时能够接收print message的。.net
/** * Type for Objective-C objects. */ typedef struct objc_object { /** * Pointer to this object's class. Accessing this directly is STRONGLY * discouraged. You are recommended to use object_getClass() instead. */ #ifndef __OBJC_RUNTIME_INTERNAL__ __attribute__((deprecated)) #endif Class isa; } *id;
id 与 NSObject *的区别对象
id与instanceTypeblog
何时应该用idtoken
init 方法的实现ci
convience constructor get
http://tewha.net/2013/02/why-you-should-use-instancetype-instead-of-id/编译器
http://stackoverflow.com/questions/7903954/why-use-id-when-we-can-just-use-nsobjectit