I keep getting Could not connect the action startServer: to target of class NSApplication
error on compile. I understand what the error is but not sure how to fix it. Somehow my xib is trying to invoke startServer method in NSApplication which doesn't exist.
It sounds as if you connected your UI element to the File's Owner object, which is an instance of NSApplication.
If you haven't done so already, you want to drag a NSObject out of the Object Library palette in Xcode 4 to the margin to the left of your layout. Once you've done that, and have selected it, choose the identity inspector and, in the Class field, enter "WindowController".
Now that you've got a representation of your WindowController, which as you said contains startServer:, then you can connect your UI element to that. Be sure your startServer method is of the form:
- (IBAction)startServer:(id)sender
or you won't be able to make the connection.
Good luck to you in your endeavors.
Simply you can fix this by two easy ways:
[[YourWindowController alloc]initWithWindowNibName:XIB_YOUR_WINDOW_CONTROLLER];
here do not create with owner. so NSApplication
will not be the owner.
[[YourWindowController alloc]init];
and in YourWindowController.m
file override init method and there call self = [super initWithWindowNibName:XIB_YOUR_WINDOW_CONTROLLER];
either 1 or 2 will fix this problem.
Happy Coding....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With