GNU Info

Info Node: (gcc-300.info)What you can and what you cannot do in +load

(gcc-300.info)What you can and what you cannot do in +load


Prev: Executing code before main Up: Executing code before main
Enter node , (file) or (file)node

What you can and what you cannot do in `+load'
----------------------------------------------

   The `+load' implementation in the GNU runtime guarantees you the
following things:

   * you can write whatever C code you like;

   * you can send messages to Objective-C constant strings (`@"this is a
     constant string"');

   * you can allocate and send messages to objects whose class is
     implemented in the same file;

   * the `+load' implementation of all super classes of a class are
     executed before the `+load' of that class is executed;

   * the `+load' implementation of a class is executed before the
     `+load' implementation of any category.


   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 `+load' in sibling
classes when you write `+load' of a class.  The order in which sibling
classes receive `+load' is not guaranteed.

   The order in which `+load' and `+initialize' are called could be
problematic if this matters.  If you don't allocate objects inside
`+load', it is guaranteed that `+load' is called before `+initialize'.
If you create an object inside `+load' the `+initialize' method of
object's class is invoked even if `+load' was not invoked.  Note if you
explicitly call `+load' on a class, `+initialize' will be called first.
To avoid possible problems try to implement only one of these methods.

   The `+load' method is also invoked when a bundle is dynamically
loaded into your running program.  This happens automatically without
any intervening operation from you.  When you write bundles and you
need to write `+load' you can safely create and send messages to
objects whose classes already exist in the running program.  The same
restrictions as above apply to classes defined in bundle.


automatically generated by info2www version 1.2.2.9