Quartz/TLayer mod to create window via action fails "Could not connect the action"
Quartz/TLayer mod to create window via action fails "Could not connect the action"
- Subject: Quartz/TLayer mod to create window via action fails "Could not connect the action"
- From: Kurt Bigler <email@hidden>
- Date: Mon, 07 Nov 2005 00:46:02 -0800
As a learning project, I wanted to try changing a single-window sample app
to be multi-window, while avoiding "document" functionality for the moment.
I picked this sample app which gets installed with the dev tools:
/Developer/Examples/Quartz/TLayer/
because it already has a separate nib file for the window, whereas a lot of
the Cocoa sample code I have been looking at is single-window stuff with
everything in a single nib making it hard to go to a multi-window situation.
As a first step I added the standard File menu to MainMenu.nib, and tried
connecting the "New" menu to an action which would create a window.
The AppDelegate class already has basically the IBAction I need, called
showTLayerDemoWindow:
@interface AppDelegate : NSObject
{
TLayerDemo *shadowDemo;
}
- (IBAction)showTLayerDemoWindow:(id)sender;
There is more in the implementation that needs to change to allow multiple
windows, but I thought I'd just start by having the single window not show
at startup (that part was easy), but show instead when the "New" command is
invoked.
IB let me make the connection from the "New" menu item to the
showTLayerDemoWindow action in the AppDelegate instance in MainMenu.nib.
But at run time I get the error:
> 2005-11-07 00:09:06.530 TLayer[4612] Could not connect the action
> showShadowDemoWindow: to target of class AppDelegate
In searching the archives and googling a bit, this error usually has to do
with the class being out of sync with the nib such that the target method is
not actually present.
But in this case I verified in the debugger that if I allow the window to be
created in its original way by not commenting out the body of
applicationDidFinishLaunching in the AppDelegate implementation:
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
[self showTLayerDemoWindow:self];
}
that in fact the method
- (IBAction)showTLayerDemoWindow:(id)sender
is being invoked by
- (void)applicationDidFinishLaunching:(NSNotification *)notification
So the method that the nib connection is apparently unable to find actually
exists and is being invoked.
I also don't understand why the IBAction tag is there at all, since the app
apparently creates the window programatically rather than by an action, but
perhaps it is just a leftover from some other app on which this sample app
was based. There doesn't seem to be any easy way to discover connections to
a particular action globally in a nib file, so I haven't proven it isn't
used, but there would seem to be no purpose for it since a 2nd window can't
be created and the app quits when the window is closed.
I have almost no experience with Cocoa so I'm hoping there is some really
obvious problem here that someone can point out.
Thanks in advance for any help.
-Kurt Bigler
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden