I have a project with 3 .xib files, MainMenu, FileUploadView, FileBrowseView.
-
MainMenu has a NSPanel, it’s owner is AppDelegate, and AppDelegate has an outlet to NSPanel called FilePanel. The NSView below the NSPanel is called filePanelView and also has an outlet in AppDelegate.
-
FileUploadView is an NSView, it’s owner is FileUploadViewController. It has an outlet called uploadView in the controller.
- FileBrowseView is similar, owner is FileBrowseViewController, has an outlet called browseView.
So in App delegate I have the following code:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
fileBrowseViewController = [[FileBrowseViewController alloc]
initWithNibName:@"FileBrowseView" bundle:nil];
}
- (IBAction)importHandsClicked:(id)sender {
[NSApp activateIgnoringOtherApps:YES];
[filePanel setIsVisible:YES];
[filePanelView addSubview:[fileBrowseViewController browseView]];
}
The action does make filePanel visible, but it doesn’t add the browseView to it. Am I doing something wrong?
Check that
[fileBrowseViewController browserView]is notnil.This is highly probably, especially if you forgot or failed to link your
browseViewIBOutlet to the actual UIView that represents yourFileBrowseViewinstance in InterfaceBuilder.[EDIT]
For more info about connecting outlets, see Apple’s InterfaceBuilder Help here (including tutorial video).