-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Objective C Memory Management Essentials
By :

If you have experience in other programming languages, such as Java, and are coming to Objective-C now, forget about constructors, they don't exist in Objective-C. Constructors are language-level constructs that merge the allocation and initialization actions, but they have restrictions:
They don't return anything. While the Objective-C class initialization method, + (void
) initialize, does not return anything, the default—(id
) init
method of an Objective-C class returns an object of the type id
.
The constructor's name must be identical with the class.
When you call the superclass, being the first statement is a must.
The last point ensures you won't deal with garbage data, but this is a restriction. In Objective-C, as in C, without this restriction, you, the programmer, have more flexibility and power, but it is also your responsibility to deal with garbage data.
Change the font size
Change margin width
Change background colour