Up

# NSApplication

### Authors

Scott Christley (`scottc@net-community.com`)
Felipe A. Rodriguez (`far@ix.netcom.com`)
Richard Frith-Macdonald (`richard@brainstorm.co.uk`)

> The one and only application class

Copyright: (C) 1996,1999 Free Software Foundation, Inc.

# Software documentation for the NSApplication class

## NSApplication : NSResponder

> Declared in:
>   AppKit/NSApplication.h

> Conforms to:
>   NSCoding

Description forthcoming.

Method summary

- -orderFrontColorPanel:
- -orderFrontDataLinkPanel:
- -activateContextHelpMode:
- -showHelp:
- -orderFrontHelpPanel:
- -runPageLayout:
- +detachDrawingThread:toTarget:withObject:
- +sharedApplication
- -abortModal
- -activateIgnoringOtherApps:
- -addWindowsItem:title:filename:
- -applicationIconImage
- -arrangeInFront:
- -beginModalSessionForWindow:
- -beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
- -cancelUserAttentionRequest:
- -changeWindowsItem:title:filename:
- -context
- -currentEvent
- -deactivate
- -delegate
- -discardEventsMatchingMask:beforeEvent:
- -endModalSession:
- -endSheet:
- -endSheet:returnCode:
- -finishLaunching
- -hide:
- -hideOtherApplications:
- -isActive
- -isHidden
- -isRunning
- -keyWindow
- -mainMenu
- -mainWindow
- -makeWindowsPerform:inOrder:
- -miniaturizeAll:
- -modalWindow
- -nextEventMatchingMask:untilDate:inMode:dequeue:
- -orderFrontStandardAboutPanel:
- -orderFrontStandardAboutPanelWithOptions:
- -orderFrontStandardInfoPanel:
- -orderFrontStandardInfoPanelWithOptions:
- -orderedDocuments
- -orderedWindows
- -postEvent:atStart:
- -preventWindowOrdering
- -registerServicesMenuSendTypes:returnTypes:
- -removeWindowsItem:
- -replyToApplicationShouldTerminate:
- -reportException:
- -requestUserAttention:
- -run
- -runModalForWindow:
- -runModalForWindow:relativeToWindow:
- -runModalSession:

### detachDrawingThread:toTarget:withObject:

+ (void) detachDrawingThread: (SEL)selector toTarget: (id)target withObject: (id)argument;

Description forthcoming.

### sharedApplication

+ (NSApplication*) sharedApplication;

Description forthcoming.

### abortModal

- (void) abortModal;

Description forthcoming.

### activateIgnoringOtherApps:

- (void) activateIgnoringOtherApps: (BOOL)flag;

Description forthcoming.

### addWindowsItem:title:filename:

- (void) addWindowsItem: (NSWindow*)aWindow title: (NSString*)aString filename: (BOOL)isFilename;

Description forthcoming.

### applicationIconImage

- (NSImage*) applicationIconImage;

Description forthcoming.

### arrangeInFront:

- (void) arrangeInFront: (id)sender;

Description forthcoming.

### beginModalSessionForWindow:

- (NSModalSession) beginModalSessionForWindow: (NSWindow*)theWindow;

Description forthcoming.

### beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:

- (void) beginSheet: (NSWindow*)sheet modalForWindow: (NSWindow*)docWindow modalDelegate: (id)modalDelegate didEndSelector: (SEL)didEndSelector contextInfo: (void*)contextInfo;

Description forthcoming.

### cancelUserAttentionRequest:

- (void) cancelUserAttentionRequest: (int)request;

Description forthcoming.

### changeWindowsItem:title:filename:

- (void) changeWindowsItem: (NSWindow*)aWindow title: (NSString*)aString filename: (BOOL)isFilename;

Changes the Window menu item associated with aWindow to aString. If no associated window item exists, one is created. If isFilename is `YES`, then aString is assumed to be a filename representation the way [NSWindow -setTitleWithRepresentedFilename:] would format it, otherwise the string is displayed literally in the menu item.

### context

- (NSGraphicsContext*) context;

Description forthcoming.

### currentEvent

- (NSEvent*) currentEvent;

Description forthcoming.

### deactivate

- (void) deactivate;

Description forthcoming.

### delegate

- (id) delegate;

Returns the applications delegate, as set by the -setDelegate: method.

The application delegate will automatically be sent various notifications (as long as it implements the appropriate methods) when application events occur. The method to handle each of these notifications has name mirroring the notification name, so for instance an NSApplicationDidBecomeActiveNotification is handled by an `applicationDidBecomeActive:` method.

- NSApplicationDidBecomeActiveNotification
- NSApplicationDidFinishLaunchingNotification
- NSApplicationDidHideNotification
- NSApplicationDidResignActiveNotification
- NSApplicationDidUnhideNotification
- NSApplicationDidUpdateNotification
- NSApplicationWillBecomeActiveNotification
- NSApplicationWillFinishLaunchingNotification
- NSApplicationWillHideNotification
- NSApplicationWillResignActiveNotification
- NSApplicationWillTerminateNotification
- NSApplicationWillUnhideNotification
- NSApplicationWillUpdateNotification

The delegate is also sent various messages to ask for authorisation to perform actions, or to ask it to perform actions (again, as long as it implements the appropriate methods).

- applicationShouldTerminateAfterLastWindowClosed:
- applicationShouldOpenUntitledFile:
- applicationOpenUntitledFile:
- applicationShouldTerminate:

The delegate is also called upon to respond to any actions which are not handled by a window, a window delgate, or by the application object itsself.. This is controlled by the -targetForAction: method.

Finally, the application delegate is responsible for handling messages sent to the application from remote processes (see the section documenting distributed objects for NSPasteboard ).

### discardEventsMatchingMask:beforeEvent:

- (void) discardEventsMatchingMask: (unsigned int)mask beforeEvent: (NSEvent*)lastEvent;

Description forthcoming.

### endModalSession:

- (void) endModalSession: (NSModalSession)theSession;

Description forthcoming.

### endSheet:

- (void) endSheet: (NSWindow*)sheet;

Description forthcoming.

### endSheet:returnCode:

- (void) endSheet: (NSWindow*)sheet returnCode: (int)returnCode;

Description forthcoming.

### finishLaunching

- (void) finishLaunching;

Description forthcoming.

### hide:

- (void) hide: (id)sender;

Description forthcoming.

### hideOtherApplications:

- (void) hideOtherApplications: (id)sender;

Description forthcoming.

### isActive

- (BOOL) isActive;

Description forthcoming.

### isHidden

- (BOOL) isHidden;

Description forthcoming.

### isRunning

- (BOOL) isRunning;

Description forthcoming.

### keyWindow

- (NSWindow*) keyWindow;

Description forthcoming.

### mainMenu

- (NSMenu*) mainMenu;

Description forthcoming.

### mainWindow

- (NSWindow*) mainWindow;

Description forthcoming.

### makeWindowsPerform:inOrder:

- (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag;

Description forthcoming.

### miniaturizeAll:

- (void) miniaturizeAll: (id)sender;

Description forthcoming.

### modalWindow

- (NSWindow*) modalWindow;

Returns the window that is part of the current modal session, if any.

See -runModalForWindow:

### nextEventMatchingMask:untilDate:inMode:dequeue:

- (NSEvent*) nextEventMatchingMask: (unsigned int)mask untilDate: (NSDate*)expiration inMode: (NSString*)mode dequeue: (BOOL)flag;

Description forthcoming.

### orderFrontStandardAboutPanel:

- (void) orderFrontStandardAboutPanel: (id)sender;

Description forthcoming.

### orderFrontStandardAboutPanelWithOptions:

- (void) orderFrontStandardAboutPanelWithOptions: (NSDictionary*)dictionary;

Description forthcoming.

### orderFrontStandardInfoPanel:

- (void) orderFrontStandardInfoPanel: (id)sender;

Description forthcoming.

### orderFrontStandardInfoPanelWithOptions:

- (void) orderFrontStandardInfoPanelWithOptions: (NSDictionary*)dictionary;

Description forthcoming.

### orderedDocuments

- (NSArray*) orderedDocuments;

Description forthcoming.

### orderedWindows

- (NSArray*) orderedWindows;

Description forthcoming.

### postEvent:atStart:

- (void) postEvent: (NSEvent*)event atStart: (BOOL)flag;

Description forthcoming.

### preventWindowOrdering

- (void) preventWindowOrdering;

Description forthcoming.

### registerServicesMenuSendTypes:returnTypes:

- (void) registerServicesMenuSendTypes: (NSArray*)sendTypes returnTypes: (NSArray*)returnTypes;

Description forthcoming.

### removeWindowsItem:

- (void) removeWindowsItem: (NSWindow*)aWindow;

Description forthcoming.

### replyToApplicationShouldTerminate:

- (void) replyToApplicationShouldTerminate: (BOOL)shouldTerminate;

Description forthcoming.

### reportException:

- (void) reportException: (NSException*)anException;

Description forthcoming.

### requestUserAttention:

- (int) requestUserAttention: (NSRequestUserAttentionType)requestType;

Description forthcoming.

### run

- (void) run;

Description forthcoming.

### runModalForWindow:

- (int) runModalForWindow: (NSWindow*)theWindow;

Description forthcoming.

### runModalForWindow:relativeToWindow:

- (int) runModalForWindow: (NSWindow*)theWindow relativeToWindow: (NSWindow*)docWindow;

Description forthcoming.

### runModalSession:

- (int) runModalSession: (NSModalSession)theSession;

Processes any events for a modal session described by the theSession variable. Before processing the events, it makes the session window key and orders the window front, so there is no need to do this separately. When finished, it returns the state of the session (i.e. whether it is still running or has been stopped, etc)

If there are no pending events for the session, this method returns immediately.

Up