222
The
is a method that is not overridden by categories. If a class and a category of it both imple-
+load
ment
, both methods are invoked. This allows some additional initializations to be performed
+load
in a category.
This mechanism is not intended to be a replacement for
limitations when you decide to use it instead of
8.1.1. What you can and what you cannot do in
The
implementation in the GNU runtime guarantees you the following things:
+load
you can write whatever C code you like;
•
you can send messages to Objective-C constant strings (
•
you can allocate and send messages to objects whose class is implemented in the same file;
•
the
implementation of all super classes of a class are executed before the
•
+load
is executed;
the
implementation of a class is executed before the
•
+load
In particular, the following things, even if they can work in a particular case, are not guaranteed:
allocation of or sending messages to arbitrary objects;
•
allocation of or sending messages to objects whose classes have a category implemented in the
•
same file;
You should make no assumptions about receiving
a class. The order in which sibling classes receive
The order in which
+load
don't allocate objects inside
create an object inside
was not invoked. Note if you explicitly call
avoid possible problems try to implement only one of these methods.
The
method is also invoked when a bundle is dynamically loaded into your running program.
+load
This happens automatically without any intervening operation from you. When you write bundles and
you need to write
+load
exist in the running program. The same restrictions as above apply to classes defined in bundle.
8.2. Type encoding
The Objective-C compiler generates type encodings for all the types. These type encodings are used
at runtime to find out information about selectors and methods and about objects and classes.
The types are encoded in the following way:
char
unsigned char
short
unsigned short
int
and
+initialize
, it is guaranteed that
+load
the
+load
+initialize
you can safely create and send messages to objects whose classes already
c
C
s
S
i
Chapter 8. GNU Objective-C runtime features
+initialize
.
+initialize
+load
@"this is a constant string"
+load
in sibling classes when you write
+load
is not guaranteed.
+load
are called could be problematic if this matters. If you
is called before
+load
method of object's class is invoked even if
on a class,
+load
+initialize
. You should be aware of its
of that class
+load
implementation of any category.
+initialize
will be called first. To
);
of
+load
. If you
+load
Need help?
Do you have a question about the ENTERPRISE LINUX 3 - USING GCC and is the answer not in the manual?
Questions and answers