I am trying to load a Nib from a C++ constructor with Objective C++. I have searched and found enough examples to get some code together but it doesn't display the window. Or any windows for that matter.
Here is an example of the contructor:
JokeSystem::JokeSystem() : fileSystem("/Library/Application Support/Jokes/")
{
try
{
randSystem = new RandSelect<std::string>
(fileSystem.getAllFileContents("%\n"));
}
catch (std::ifstream::failure)
{
NSWindowController * errorWindowControl = [[NSWindowController alloc]
initWithWindowNibName:@"ErrorWindow"];
[errorWindowControl showWindow: nil];
}
}
The purpose of the contructor is to load the contents of a directory into a string. What I am try to do is display the error window when the files fail to open.
ErrorWindow.nib has a single window with an OK button and a NSTextView
for the error, I set up a NSWindowController
in the nib and connected it to the window.
My only link has been that most examples show this [errorWindowControl showWindow: self]
;
rather than showWindow: nil
but because this is a C++ constructor I it doesn't have self
and this
doesn't work.
If it matters this contructor is called from the awakeFromNib
method of the MainMenu.nib
's primary NSObject
.
Thanks