Getting a notification when a nib loads

Discussion in 'Mac Programming' started by ATG, Aug 6, 2006.

  1. ATG
    macrumors regular

    Joined:
    Aug 7, 2005
    #1
    I'm loading a nib with:
    Code:
    [NSBundle loadNibNamed:@"MyNib" owner:self];
    How can I get an awakeFromNib style message when it finishes loading?

    BTW awakeFromNib doesn't work
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    awakeFromNib gets called from classes within the nib. You generally call loadNibNamed:eek:wner: from within the class that's in the nib, not outside it.
     
  3. ATG
    thread starter macrumors regular

    Joined:
    Aug 7, 2005
    #3
    Doesn't matter. I've figured out that it's not the secondary nib that's the problem but the document nib.

    It seems that the
    Code:
    - - (void)windowControllerDidLoadNib:(NSWindowController *) aController
    doesn't do what I says and not everything in the nib has completely loaded when it gets called.

    I was trying to display a sheet to appear when a new document was created or opened (something like that anyway. I can't be bothered to explain fully :eek:).

    I thought that if I put the [NSApp beginSheet: etc:] message in the windowControllerDidLoadNib method then the sheet would appear after the nib had loaded and it would 'stick' to the window. Why doesn't that work.

    Anyway, I fixed it by putting it in a menu so the nib would of loaded by then anyway.
     
  4. macrumors 6502

    Joined:
    Jul 25, 2006
    #4
    It appears from the documentation that the method blocks until the nib is loaded successfully (as opposed from delaying it somewhere in the run loop or a secondary thread) because it returns a BOOL that indicates whether the load was a success or not.
     

Share This Page