Stewart Stremler wrote: >.. >> (I guess the 'id' is confusing me) > > The "id" is a pointer-to-some-object -- in Java, one would use "Object" > as the type. Objective-C is single-inheritiance, but there is no > required root object, so you can have multiple inheritance trees. > >> Q1. how does the constructor know what the 'id' type is? > > I don't understand the question. > > Objective C doesn't really have constructors. It just has class methods > (indicated with +) and instance methods (indicated with a -).
<Start: sticking-my-neck-out-mode="wild assumptions at what the code might mean"> Well, in main(), where I see cbuffer = [CBuffer new: 8]; I'm think that creates an object to hold 8 things. And the code in CBuffer.m at new() allocates sizeof( id ) * 8 bytes. ..Oh, maybe _all_ objects are passed around by a generic handle or proxy (don't know the right term to use here) -- namely an 'id'. Izzatit? > > For single-threaded code, singletons are *easy* in Objective C. > >> Q2. does the put do any type checking? > > If not specified, the default type for return values and arguments is > "id" (i.e., some ObjC object). If I would have declared a non-id type > in the prototype and implementation, the compiler would enforce the > type-checking; I could also add code to the -put: method to enforce > runtime type-checking, but my ObjC-fu isn't that strong yet. Oh, ok, that helps. > Regards, ..jim -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
