Help me please to find out what’s the difference between these two code snippets:
(In the snippets Foo is a class derived from Object declared in objc/Object.h)
// Snippet 1
Object* o = [Foo new];
[o free];
// Snippet 2
id o = [Foo new];
[o free];
Thanks!
EDIT
Thanks for the helpful answers! Let me share a link that I found, maybe it’ll help those, who meets the same question like me, and want to understand it better:
id_vs_NSObject.
idcan be anything and can respond to any message in the system without warning, as it could be of any type.Object *(do you meanNSObject *?) is strongly typed–the compiler assumes it only responds to methods thatObjectis known to respond to.