Programming Mac OS X with Cocoa for Beginners/Some Cocoa
essential principles  From Wikibooks, open books for an open
world Jump to: navigation, search  Previous Page: Objective C,
the language and its advantages | Next Page: Building a GUI  We
have already seen the basics of Cocoa in action. Last chapter,
we talked about inheriting from NSObject, and how we must make
sure that we call an object's chain of init methods. Here, we'll
go into more detail about this, as it's important. Then, we'll
talk about memory management.   Initialising an object properly
is your responsibility. Unlike C++, there is no automatic
constructor method, nor an automatic destructor method. However,
we can easily do without these as long as we are aware of a few
simple rules. Following the rules is necessary for success in
Cocoa.  When we instantiate an object:  id   myObject =
[NSString alloc];  All we get back is a blob of uninitialised
memory. If we were to use this object now, we'd be very unlikely
to get the results we wanted.