views:

44

answers:

2

I need to open sheet from separate NIB and wants to use its separate controller awakeFromNib to configure sheet controls.Please let me know the best way to do that.I am using 10.5 API with XCODE 3.1.4

+1  A: 

Sounds like you want to load the nib. It also sounds like NSWindowController would be of interest to you.

Peter Hosey
Yes,thanks you are correct, i need to have the sheet in seperate nib and need to manage all the sheet delegates in seperate NSWindowController subclass.I have tried to do that but panel window is always open as seperate window instead of sheet attached to my main window.please let me know if you have sample code which shows me how to attach sheet from seperate nib.Thakns
AmitSri
Turn off the panel's “Visible on Launch” property in IB. Use this method to run a panel as a sheet on another window: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/NSApplication/beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: It doesn't matter whether the panel comes from a nib or not.
Peter Hosey
Thanks,for the link. I'll try and let you know ,if still need your help
AmitSri
A: 

Hi, thanks for all to helped me. I finally, solve my sheet problem. Following is the step i have followed to show the sheet from seperate NIB.

  1. Create New NIB with panel/window having seperate UI.
  2. Created NSwindowController subclass for my Sheet.
  3. implemented - init method in sheet controll and initialize nib using initWithWindowNibName.
  4. changed the File's owner class to sheetcontroller in seperate nib.
  5. add the window reference to File's Owner window object to my panel/window in seperate NIB.
  6. imported sheetcontroller header into main app controller and finally use the following code to make the sheet working.

Profile Actions:

- (IBAction)showProfiles:(id)sender {
    ProfileSheetController *profileSheet =[[ProfileSheetController alloc] init];
    profileSheet.appController = self;
    [NSApp beginSheet:[profileSheet window]
       modalForWindow:window
        modalDelegate:self
       didEndSelector:NULL
          contextInfo:nil];
}
AmitSri