tags:

views:

43

answers:

3

Guys, what is function called after my class loaded, where i can call "self" there.

thanks advance

+1  A: 

It's not clear from your question which of the following you need:

  • when your class is linked, the +load method will be called

  • the first time your class is used, the +initialize method will be called

You can override either of those methods. If you do, take care to ensure that the class you are loading or initializing is the one you intend; otherwise if someone creates a subclass and does not override the method yours may be called twice with unpredictable results.

It is always possible to use self in any Objective-C method. It is just an implicit argument to the method, nothing special.

Graham Lee
A: 

There isn't anything that's automatically called after init is called. If you want something like that and you're subclassing NSObject, simply override -init and call a method yourself (although, if you're doing that, you may as well do whatever you want to do in init itself).

If you're subclassing something else, look in that class' docs — there may well be something that fits your needs. For example, NSManagedObject has awakeFromInsert/Fetch, etc.

iKenndac
A: 

thankss.. i just figured out ur answer that no method automatically called after init..