Re: Interface Builder Problem
Re: Interface Builder Problem
- Subject: Re: Interface Builder Problem
- From: Lars Sonchocky-Helldorf <email@hidden>
- Date: Sat, 19 Jan 2002 05:26:20 +0100
Am Samstag den, 19. Januar 2002, um 00:51, schrieb Ondra Cada:
Lars,
Lars Sonchocky-Helldorf (LSH) wrote at Sat, 19 Jan 2002 00:23:21
+0100:
LSH> Anyway, after starting the application the menu nib is obviously
not
LSH> loaded, instead a generic menu appears consisting only out of the
LSH> application menu which even doesn't contain everything I put into
the
LSH> nibs application menu (specially the "About Gomoku" menu item).
What I
LSH> am missing here? Why doesn't the menu nib getting loaded?
Probably you did not say the project to store its name into Info.plist,
or
by other words, you did not say the standard application code to load
it.
In the PB, select targets in the left sliding thing, and in the mess
which
would occur in the main editing area select the "application settings"
tab;
there is -- IIRC, about fourth block from top or so -- an editbox for
the
main NIB name: that NIB will be loaded automatically when the app
starts.
---
this all was fine, the cause was something different, it is in this
little piece of code (this is what it looks now):
NSApplicationMain(argc, argv);
controller = [Controller new: cnt];
[app setDelegate: controller];
// [app run];
The root cause was the use of [app run]; to start the application. I
changed that to NSApplicationMain(argc, argv); right after // [app
run];. Now the menu was loaded as expected but a soon as I clicked into
a menu I got dropped into the debugger with a "Program received signal:
"EXC_BAD_ACCESS", but menushortcuts seemed to work, although not as I
wanted it: When this application starts up a window is created(Note:
this window is not created from a nib but "hardcoded") , the game board
(this was always the case). It's class, Controller, is a subclass of
NSWindow. I imported that class into IB, created an instance of NSWindow
and then set the custom class to Controller. After that I connected the
outlets and action of that Instance to the menus.
Somehow that practice strikes back in a strange way. When I entered a
menu shortcut this shortcut did not act on that gameboard window created
on startup but on that particular window instance created in IB. I
thought those instances where proxies, so I expected that instance of
Controller to be a proxy for _my_ Controller but instead the window that
appears is the window created when creating the instance of NSWindow
firsthand, before changing it into a Controller.
How can I work that out? I'd like to have the menus acting on the
gameboard window.
After this I moved NSApplicationMain(argc, argv); before the creation of
controller/the gameboard window. Now the gameboard window was not longer
created on startup (the code was never reached), but the menus worked
without any problem (no longer "EXC_BAD_ACCESS").
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc
Greetings, Lars