Reputation: 780
I am new in cocoa application development. I am trying to create model based application in cocoa.
I created two windows in cocoa application say mainMenu.xib and windows2.xib. The mainMenu.xib is created while project creation and windows2.xib is manually created. Now I inserted a button on mainMenu.xib say (button1) and when clicked on button then window2.xib poped up but when click on button of second windows it is generated a error. the code is follwoing
AppDelegate.h
@interface AppDelegate : NSObject <NSApplicationDelegate>
And AppDelegate.mm
#import "AppDelegate.h"
@implementation AppDelegate
NSWindowController *AdvSettingController;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
}
- (IBAction)AdvSettingBtn:(id)sender {
AdvSettingController= [[NSWindowController alloc] initWithWindowNibName:@"window2"];
[NSApp runModalForWindow:AdvSettingController.window];
[NSApp endSheet:AdvSettingController.window];
[AdvSettingController.window orderOut:self];
}
- (IBAction)OkBtn:(id)sender {
[NSApp terminate:self];
}
- (IBAction)CancelBtn:(id)sender {
[NSApp terminate:self];
}
Now, windows2.h file for second windows(windows2.xib)
#import <Cocoa/Cocoa.h>
@interface windows2 : NSWindowController
@end
and windows2.mm
#import "windows2.h"
@interface windows2 ()
@end
@implementation windows2
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindowNibName:@"windows2"];
if (self) {
// Initialization code here.
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from
}
- (IBAction)CancelBtn:(id)sender {
[self.window close];
} **//Error is generating at run time when clicked on button of second dialog**
Upvotes: 0
Views: 66
Reputation: 6518
You are trying to connect the CancelButton
method, but the instance method is named CancelBtn
.
Upvotes: 1