Why won't my awakeFromNib fire?

Solution 1:

-awakeFromNib is sent to all object that are instantiated from the nib after all nib objects have instantiated. The owner is not one of those objects. It exists prior to deserializing the nib and is wired to the nib after loading, so it is not sent -awakeFromNib (unless of course it is instantiated by some other nib itself).

One clue here is that there's no way both -initFromChromosomePair:basepairStart:basepairEnd: and -awakeFromNib could both be called. The nib loader always calls -initWithCoder:, -initWithFrame: or -init (the rules for which is sent are in The Nib Object Life Cycle). The fact that you have some other designated initializer strongly suggests that you're manually creating this object somewhere in the code, which means this object is not "awaken from nib."

Solution 2:

Just adding a clarification: -awakeFromNib is sent to File's Owner in Cocoa, but not Cocoa Touch.

From Apple's Docs:

...

  • It sends an awakeFromNib message to the appropriate objects in the nib file that define the matching selector:
    • In Mac OS X, this message is sent to any interface objects that define the method. It is also sent to the File’s Owner and any proxy objects that define it as well.
    • In iPhone OS, this message is sent only to the interface objects that were instantiated by the nib-loading code. It is not sent to File’s Owner, First Responder, or any other proxy objects.

Solution 3:

Based on what you've told us, I believe I know what your problem is. awakeFromNib is called when an object is deserialized from a nib file. Here you have an object, which is the owner, that exists before the nib is loaded. Thus awakeFromNib would never be sent to your AlignmentViewController.h.

If you need to do something here, try using loadView instead. Or just do it after loading the nib. What is it that you're tying to do that you wanted to do it in awakeFromNib?