Why isn't the init method called in a subclassed NSArrayController?

I have subclassed NSArrayController, as MyArrayController, and it has an init method.
MyArrayController is connected in IB and it certainly works in all aspects except that the init method is never run.

Shouldn’t all instances of such objects receive a call to the init method?

(Probably irrelevant to the question: it was an ASOC object, but now converted to ObjC. When it was an ASOC it didn’t have an init handler, but now I need the init.)

If the object is loaded from a NIB, initWithCoder: is called. Or you can override awakeFromNib, this method is called after the connections are made.

That’s right!
Just replacing ‘init’ with ‘initWithCoder:’ made it work. Thanks!

This confuses me somewhat though, since I have two other classes (subclassed to NSObject) in another nib, and they respond to ‘init’. That nib is loaded via ‘initWithWindowNibName:’ from the MainMenu nib’s app delegate. The loaded nib’s owner, in turn, loads a few documents defined in a separate nib, which contains the subclassed NSArrayController, which obviously does not receive any call to ‘init’.

So, why do some classes receive an ‘init’, and some not?

How do I understand which init is used in the respective cases?
Since NSArrayController is a subclass (in several steps) of NSObject, I took for granted that ‘init’ is always called, but obviously that is not the case.

I would like to read about that in the docs, but I can not find a place where this is described. The “Model Object Implementation Guide” in Chapter “Initialization” only says “You may also, however, want to initialize an object in a different way when it is extracted from an archive. In this situation, you can customize the initialization in the initWithCoder: method.

Cocoa isn’t perfect. Apparently some init’s are called and others aren’t.
If an object is instantiated from a NIB and I don’t call the initializer myself, I don’t worry about which init. to override and override awakeFromNib.

If you want to read about init.:
The Nib Object Life Cycle
Object Initialization
subclassing NSArrayController (discussion)

When an object is loaded from a nib you shouldn’t use init methods at all but you should use awakeFromNib method. For example whne you use a binding an init can be called from an object before the binding has made. awakeFromNib is called only when everything is ready to ‘serve’ you.

It doesn’t have something to do with cocoa directly, it’s one of the limitation Objective-C have. Objective-C doesn’t have constructors like C++ does.

Thanks for the responses and the links, which was good reading (in addition to NSNibAwaking Protocol Reference).
And yes, using awakeFromNib is a much better thing to do for nib files. I have had no less than 4 classes in different nib files where I had used init, and I don’t quite know why I had init instead of awakeFromNib – maybe just dumb routine or copy/paste, but in any case the awakeFromNib is both easier and cleaner, and fits well with the other nib-related routines in the sequence: ‘windowControllerWillLoadNib:’, ‘awakeFromNib’, ‘windowControllerDidLoadNib:’ (with any ‘readFromData:…’ before all of them, but after any init).