Id vs NSObject* vs id<NSObject> There's often confusion about the difference between the following three declarations in Objective-C: id foo1;NSObject *foo2;id<NSObject> foo3;The first one is the most common. It simply declares a pointer to some Objective-C object (see /usr/include/objc/objc.h). id gives the compiler no information about the actual type of the object, so the compiler cannot do compile-time type checking for you. Thus, the compiler will let you send any (*) message to objects declared id. Actually, this is why the common idiom of [[Foo alloc] init] doesn't cause the compiler to complain.
+alloc is declared to return type id, so the compiler won't yell when you then send the returned object the message init (or even initWithMyFoo:blah). So, objects declared using id are just dynamically typed at runtime. The compiler has no useful information about the object's real type, so it can't warn you if you send it a message that it may not respond to. So how do you decide which form you want to use? And X52.9704 Source Code. Syllabus « CMSC 491 Fall ’09 — iPhone and iPod touch Development. Course Information Course Number: CMSC 491: Special Topics in Computer Science — Section 5-LEC(4533) Course Topic: iPhone and iPod touch Development Time/Place: Tuesday & Thursday 5:30–6:45pm, ACIV 013 Course Webpage: Contact Information Instructor: Daniel J. Email: danielhood@umbc.edu Office: ITE 211 (map) Office Hours: Tuesday & Thursday 7–8pm, or by appointment Course Description This course provides an in-depth study of the design, development and publication of object-oriented applications for the iPhone and iPod touch platforms using the Apple SDK.
Prerequisites: CMSC 341 — Data Structures Recommended: Competency in C or C++ (pointers, memory management, etc.) Course Objective At the conclusion of this course, you will Course Format Class will consist primarily of lecture heavily supplemented by working, downloadable code examples. Course Policies Course Webpage The class webpage listed above is a vital resource for this class. Participation Classroom Etiquette.