#import "AppDelegate.h" @interface AppDelegate () @property (strong) NSWindow *window; @property (strong) NSButton *fullscreenButton; @property (strong) NSButton *saveOnlyButton; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Create the window NSRect frame = NSMakeRect(0, 0, 600, 400); self.window = [[NSWindow alloc] initWithContentRect:frame styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable) backing:NSBackingStoreBuffered defer:NO]; [self.window setTitle:@"Fullscreen & Save Panel"]; [self.window makeKeyAndOrderFront:nil]; // Create the fullscreen and save button self.fullscreenButton = [[NSButton alloc] initWithFrame:NSMakeRect(200, 180, 200, 50)]; [self.fullscreenButton setTitle:@"Go Fullscreen & Save"]; [self.fullscreenButton setTarget:self]; [self.fullscreenButton setAction:@selector(fullscreenButtonClicked:)]; [[self.window contentView] addSubview:self.fullscreenButton]; // Create the save only button self.saveOnlyButton = [[NSButton alloc] initWithFrame:NSMakeRect(200, 100, 200, 50)]; [self.saveOnlyButton setTitle:@"Open Save Panel"]; [self.saveOnlyButton setTarget:self]; [self.saveOnlyButton setAction:@selector(saveOnlyButtonClicked:)]; [[self.window contentView] addSubview:self.saveOnlyButton]; [self.window center]; } - (void)applicationWillTerminate:(NSNotification *)aNotification { // Insert code here to tear down your application } - (void)fullscreenButtonClicked:(id)sender { // Go fullscreen [self.window toggleFullScreen:nil]; // Open "Save As" panel (modal) [self openSavePanel]; } - (void)saveOnlyButtonClicked:(id)sender { // Open "Save As" panel (modal) [self openSavePanel]; } - (void)openSavePanel { // Open "Save As" panel in modal mode NSSavePanel *savePanel = [NSSavePanel savePanel]; [savePanel setTitle:@"Save As"]; [savePanel setMessage:@"Choose a location to save the file."]; [savePanel setAllowedFileTypes:@[@"txt", @"pdf"]]; // Make the save panel modal NSInteger result = [savePanel runModal]; // This will make the panel modal if (result == NSModalResponseOK) { NSURL *selectedFileURL = [savePanel URL]; // Handle the file URL here if necessary NSLog(@"File will be saved at: %@", selectedFileURL.path); } } @end