Hi,
I'm trying to add a button to my MainWindow programatically, but it isn't working... could anyone have a look at the code for me and point out my mistake? The error is "[NSView addButtonWithTitle:]: unrecognised selector sent to instance xxx".
TestAppDelegate.h:
TestAppDelegate.m
Kind Regards
I'm trying to add a button to my MainWindow programatically, but it isn't working... could anyone have a look at the code for me and point out my mistake? The error is "[NSView addButtonWithTitle:]: unrecognised selector sent to instance xxx".
TestAppDelegate.h:
Code:
#import <Cocoa/Cocoa.h>
@interface TestAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
NSButton *bExit;
}
@property (assign) IBOutlet NSWindow *window;
@property (nonatomic, retain) NSButton *bExit;
- (void)bExit_click;
@end
Code:
#import "TestAppDelegate.h"
@implementation TestAppDelegate
@synthesize window, bExit;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
NSScreen *screen = [[NSScreen screens] objectAtIndex:0];
//NSLog(@"test");
bExit = [[window contentView] addButtonWithTitle:@"Exit"];
//Previously I was doing bExit = [NSButton alloc]; [bExit init]; and then adding it to the contentView via addObject... that wasn't working either.
[[window contentView] enterFullScreenMode:screen withOptions:nil];
}
- (void)bExit_click {
[[window contentView] exitFullScreenModeWithOptions:nil];
}
@end
Kind Regards