*Really* Understanding Cocoa
*Really* Understanding Cocoa
- Subject: *Really* Understanding Cocoa
- From: Udo Ludtke <email@hidden>
- Date: Wed, 25 Dec 2002 17:48:33 -0500
Hi There,
I have been getting into cocoa using "Learning Cocoa", Garfinkel's Building
Cocoa Applications", Hillegass' "Cocoa programming for Mac OS X" books, and
Beam's examples on the O'Reilly Network and the examples at stepwise.com on
the Web.
I can make the examples work, but I still do not have a proper grasp how
Cocoa works.
When I learned C, most of the books explained the C language in terms of
hardware, that is, in locations in memory. I may be biased because I started
from a hardware background, but these explanations made perfectly sense to
me, even though they were oversimplified.
I have never seen a complete explanation of Cocoa in those terms--I have
seen bits an pieces of it here and there. Basic Cocoa terms are seldom
explained by reducing them to a lower level. That Cocoa uses a totally new
terminology, does not help either. I am looking for an explanation that
would go as follows: (The example below is probably wrong, but hopefully it
will get the idea across.)
---------------------------------
In Cocoa, an object is a block of memory. The name of the object is a
compiler mnemonic that reduces, during compilation, to the staring memory
location of the object's memory block. The size of the object's memory block
depends on the number and type of outlets and methods declared in the object
and the number of methods inherited from its super class. However, the super
class methods are represented in the object only as pointers to the methods
in the Class definition, the super class methods are not copied into the
object's memory space.
An outlet is a memory location that is defined to store a specific data
type, such as int or char, or that is defined, as ID, to hold a pointer to
another object. The size of the assigned memory block depends on the type of
variable specified. The name of the outlet variable is a compiler mnemonic
that reduces, during compilation, to the staring memory location of the
outlet variable, expressed as an offset from the memory start address of the
object in which the outlet variable is defined. Because the memory address
is an offset, it is not a global variable.
If we use the Interface Builder to connect an outlet variable that has been
defined to hold an integer, to, say, a text field object, then we copy the
address of the outlet variable into the memory location assigned as the
content of the text field. Thus the text field address contains a pointer,
and the text field always displays what is stored at the address of the
outlet variable.
If, on the other hand, we use the Interface Builder to connect an outlet
variable that has been defined as ID to hold a pointer, to, say, a text
field object, then we copy the address assigned to the content of the text
field to the outlet variable. Thus The outlet variable contains a pointer to
the text field, and the outlet variable always contains the content of the
text filed.
---------------------------------
Has anybody done such a series of Cocoa explanations in one place?
Maybe I should try to write them up, and then I would understand Cocoa ;-).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.