- Inherits from:
- NSResponder : NSObject
- Conforms to:
- NSCoding
- (NSResponder)
- NSObject (NSObject)
Declared in:
- AppKit/NSApplication.h
- AppKit/NSColorPanel.h
- AppKit/NSDataLinkPanel.h
- AppKit/NSHelpManager.h
- AppKit/NSPageLayout.h
An NSApplication object manages an application's main event loop in addition to resources used by all of that application's objects.
- keyWindow | Returns an NSWindow representing the key window. |
- mainMenu | Returns an NSWindow representing the main window. |
- registerServicesMenuSendTypes:returnTypes: | Specifies which services are valid for this application. |
- runModalForWindow: | Runs a modal event loop for the specified NSWindow. |
The NSApplication class provides the central framework for
your application's execution. Every application must have exactly
one instance of NSApplication (or a subclass of NSApplication).
Your program's main()
function
should create this instance by invoking the sharedApplication class method. After
creating the NSApplication object, the main()
function
should load your application's main nib file and then start the
event loop by sending the NSApplication object a run message. If
you create an Application project in Project Builder, this main()
function
is created for you. The main()
function
Project Builder creates begins by calling a function named NSApplicationMain()
,
which is functionally similar to the following:
void NSApplicationMain(int argc, char *argv[]) { [NSApplication sharedApplication]; [NSBundle loadNibNamed:@"myMain" owner:app]; [NSApp run]; }
The sharedApplication class
method initializes the display environment and connects your program to
the Window Server and the Display server. The NSApplication object
maintains a list of all the NSWindows the application uses, so it
can retrieve any of the application's NSViews. sharedApplication also
initializes the global variable NSApp
,
which you use to retrieve the NSApplication instance. sharedApplication only
performs the initialization once; if you invoke it more than once,
it simply returns the NSApplication object it created previously.
NSApplication's main purpose is to receive events from the
Window Server and distribute them to the proper NSResponders. NSApp
translates
an event into an NSEvent object, then forwards the NSEvent to the
affected NSWindow object. All keyboard and mouse events go directly
to the NSWindow associated with the event. The only exception to
this rule is if the Command key is pressed when a key-down event
occurs; in this case, every NSWindow has an opportunity to respond
to the event. When an NSWindow receives an NSEvent from NSApp
,
it distributes it to the objects in its view hierarchy.
The NSApplication class sets up autorelease pools (instances
of the NSAutoreleasePool class) during initialization and inside
the event loop-specifically, within its init (or sharedApplication)
and run methods. Similarly,
the methods the Application Kit adds to NSBundle employ autorelease
pools during the loading of nib files. These autorelease pools aren't
accessible outside the scope of the respective NSApplication and
NSBundle methods. Typically, an application creates objects either
while the event loop is running or by loading objects from nib files,
so this usually isn't a problem. However, if you do need to use
Cocoa classes within the main()
function
itself (other than to load nib files or to instantiate NSApplication),
you should create an autorelease pool before using the classes and
then release the pool when you're done. For more information,
see the NSAutoreleasePool class specification in the Foundation
Framework Reference.
Rarely do you need to create a custom NSApplication subclass.
In general, a better design is to separate the code that embodies
your program's functionality into a number of custom objects.
Usually, those custom objects are subclasses of NSObject. Methods
defined in your custom objects can be invoked from a small dispatcher
object without being closely tied to NSApp
.
The only reason to subclass NSApplication is if you need to provide
your own special response to messages that are routinely sent to NSApp
.
(Even then, NSApp
's delegate is
often given a chance to respond to such messages, so it's more
appropriate to implement the delegate methods.) To use a custom
subclass of NSApplication, simply send sharedApplication to your custom
class rather than directly to NSApplication. If you create your
application in Project Builder, set the application class on the
Project Attributes inspector, and Project Builder will update the main()
function
accordingly. As mentioned previously, NSApp
uses
autorelease pools in its init and run methods; if
you override these methods, you'll need to create your own autorelease
pools.
You can assign a delegate to NSApp
.
The delegate responds to certain messages on behalf of NSApp
. Some
of these messages, such as application:openFile:,
ask the delegate to perform an action. Another message, applicationShouldTerminate:,
lets the delegate determine whether the application should be allowed
to quit. The NSApplication class sends these messages directly to
its delegate.
NSApp
also posts notifications
to the application's default notification center. Any object may
register to receive one or more of the notifications posted by NSApp
by
sending the message addObserver:selector:name:object: to
the default notification center (an instance of the NSNotificationCenter class). NSApp
's
delegate is automatically registered to receive these notifications
if it implements certain delegate methods. For example, NSApp
posts
notifications when it is about to be done launching the application
and when it is done launching the application (NSApplicationWillFinishLaunchingNotification
and NSApplicationDidFinishLaunchingNotification
).
The delegate has an opportunity to respond to these notifications
by implementing the methods applicationWillFinishLaunching: and applicationDidFinishLaunching:.
If the delegate wants to be informed of both events, it implements both
methods. If it only needs to know when the application is finished
launching, it implements only applicationDidFinishLaunching:. For
more information on notifications, see the NSNotificationCenter
class specification in the Foundation Framework Reference.
These are possible return values for - runModalForWindow: and - runModalSession::
Constant | Description |
NSRunStoppedResponse |
Modal session was broken with stopModal |
NSRunAbortedResponse |
Modal session was broken with abortModal |
NSRunContinuesResponse |
Modal session is continuing (returned by runModalSession: only) |
- Creating and initializing an NSApplication
- + sharedApplication
- - finishLaunching
- Changing the active application
- - activateIgnoringOtherApps:
- - isActive
- - deactivate
- Running the event loop
- - run
- - isRunning
- - stop:
- - runModalForWindow:
- - stopModal
- - stopModalWithCode:
- - abortModal
- - beginModalSessionForWindow:
- - runModalSession:
- - endModalSession:
- - sendEvent:
- Getting, removing, and posting events
- - currentEvent
- - nextEventMatchingMask:untilDate:inMode:dequeue:
- - discardEventsMatchingMask:beforeEvent:
- - postEvent:atStart:
- Managing windows
- - keyWindow
- - mainWindow
- - windowWithWindowNumber:
- - windows
- - makeWindowsPerform:inOrder:
- - setWindowsNeedUpdate:
- - updateWindows
- - miniaturizeAll:
- - preventWindowOrdering
- Hiding all windows
- - hide:
- - isHidden
- - unhide:
- - unhideWithoutActivation
- Setting the application's icon
- - setApplicationIconImage:
- - applicationIconImage
- Getting the main menu
- - setMainMenu:
- - mainMenu
- - setAppleMenu:
- Managing the Window menu
- - setWindowsMenu:
- - windowsMenu
- - arrangeInFront:
- - addWindowsItem:title:filename:
- - changeWindowsItem:title:filename:
- - removeWindowsItem:
- - updateWindowsItem:
- Managing the Services menu
- - setServicesMenu:
- - servicesMenu
- - registerServicesMenuSendTypes:returnTypes:
- - validRequestorForSendType:returnType:
- - setServicesProvider:
- - servicesProvider
- Showing standard panels
- - orderFrontColorPanel:
- - runPageLayout:
- Displaying help
- - showHelp:
- - activateContextHelpMode:
- Sending action messages
- - sendAction:to:from:
- - tryToPerform:with:
- - targetForAction:
- - targetForAction:to:from:
- + detachDrawingThread:toTarget:withObject:
- Getting the display context
- - context
- Reporting an exception
- - reportException:
- Terminating the application
- - terminate:
- Assigning a delegate
- - setDelegate:
- - delegate
+ (void)detachDrawingThread:(SEL)selector
toTarget:(id)target
withObject:(id)argument
public static NSApplication sharedApplication()
NSApp
), creating
it if it doesn't exist yet. This method also
makes a connection to the Window Server and completes other initialization.
Your program should invoke this method as one of the first statements
in main()
; this is done
for you if you create your application with Project Builder. To
retrieve the NSApplication instance after it has been created, use
the global variable NSApp
or invoke
this method. See Also: - run, - terminate:
- (void)abortModal
NSRunAbortedResponse
. abortModal is typically
sent by objects registered with the default NSRunLoop; for example,
by objects that have registered a method to be repeatedly invoked
by the NSRunLoop through the use of an NSTimer object. This method can also abort a modal session created by beginModalSessionForWindow:, provided the loop that runs the modal session (by invoking runModalSession:) catches NSAbortModalException.
See Also: - endModalSession:, - stopModal, - stopModalWithCode:
- (void)activateContextHelpMode:(id)sender
Most applications don't use this method. Instead, applications enter context-sensitive mode when the user presses the Help key. Applications exit context-sensitive help mode upon the first event after a help window is displayed.
See Also: - showHelp:
- (void)activateIgnoringOtherApps:(BOOL)flag
NO
,
the application is activated only if no other application is currently
active. If flag is YES
,
the application activates regardless. flag is
normally set to NO
. When the Workspace
Manager launches an application, using a value of NO
for flag allows
the application to become active if the user waits for it to launch,
but the application remains unobtrusive if the user activates another
application. Regardless of the setting of flag,
there may be a time lag before the application activates-you should
not assume the application will be active immediately after sending
this message.
You rarely need to invoke this method. Under most circumstances, the Application Kit takes care of proper activation. However, you might find this method useful if you implement your own methods for interapplication communication.
You don't need to send this message to make one of the application's NSWindows key. When you send a makeKeyWindow message to an NSWindow, you ensure the NSWindow will be the key window when the application is active.
See Also: - deactivate, - isActive
- (void)addWindowsItem:(NSWindow
*)aWindow
title:(NSString *)aString
filename:(BOOL)isFilename
NO
, aString appears
literally in the menu. If isFilename is YES
, aString is
assumed to be a converted path name with the name of the file preceding
the path (the way NSWindow's setTitleWithRepresentedFilename: method
shows a title). If an item for aWindow already
exists in the Window menu, this method has no effect. You rarely invoke
this method because an item is placed in the Window menu for you
whenever an NSWindow's title is set.See Also: - changeWindowsItem:title:filename:, - setTitle: (NSWindow)
- (NSImage *)applicationIconImage
See Also: - setApplicationIconImage:
- (void)arrangeInFront:(id)sender
See Also: - addWindowsItem:title:filename:, - removeWindowsItem:, - makeKeyAndOrderFront: (NSWindow)
- (NSModalSession)beginModalSessionForWindow:(NSWindow
*)aWindow
beginModalSessionForWindow: only
sets up the modal session. To actually run the session, use runModalSession:. beginModalSessionForWindow: should
be balanced by endModalSession:.
Make sure these two messages are sent within the same exception
handling scope. That is, if you send beginModalSessionForWindow: inside
an NS_DURING
construct,
you must send endModalSession: before NS_ENDHANDLER
.
If
an exception is raised, beginModalSessionForWindow: arranges
for proper cleanup. Do not use NS_DURING
constructs
to send an endModalSession: message in
the event of an exception.
A loop using these methods is similar to a modal event loop run with runModalForWindow:, except the application can continue processing between method invocations.
- (void)changeWindowsItem:(NSWindow
*)aWindow
title:(NSString *)aString
filename:(BOOL)isFilename
NO
, aString appears
literally in the menu. If isFilename is YES
, aString is
assumed to be a converted path name with the file's name preceding
the path (the way NSWindow's setTitleWithRepresentedFilename: places
a title). See Also: - addWindowsItem:title:filename:, - removeWindowsItem:, - setTitle: (NSWindow)
- (NSGraphicsContext *)context
- (NSEvent *)currentEvent
NSApp
receives events
and forwards the current event to the affected NSWindow object,
which then distributes it to the objects in its view hierarchy. See Also: - discardEventsMatchingMask:beforeEvent:, - postEvent:atStart:, - sendEvent:
- (void)deactivate
See Also: - activateIgnoringOtherApps:
See Also: - setDelegate:
- (void)discardEventsMatchingMask:(unsigned
int)mask
beforeEvent:(NSEvent *)lastEvent
NSApp
. mask can contain these constants:
NSLeftMouseDownMask
NSLeftMouseUpMask
NSRightMouseDownMask
NSRightMouseUpMask
NSMouseMovedMask
NSLeftMouseDraggedMask
NSRightMouseDraggedMask
NSMouseEnteredMask
NSMouseExitedMask
NSKeyDownMask
NSKeyUpMask
NSFlagsChangedMask
NSPeriodicMask
NSCursorUpdateMask
NSAnyEventMask
Use
this method to ignore events that occur before a particular kind
of event. For example, suppose your application has a tracking loop
that you exit when the user releases the mouse button, and you want
to discard all events that occurred during that loop. You use NSAnyEventMask
as
the mask argument and pass the mouse up event as the lastEvent argument.
Passing the mouse-up event as lastEvent ensures
that any events that might have occurred after the mouse-up event
(that is, that appear in the queue after the mouse-up event) don't
get discarded.
See Also: - nextEventMatchingMask:untilDate:inMode:dequeue:
- (void)endModalSession:(NSModalSession)session
See Also: - runModalSession:
- (void)finishLaunching
See Also: - applicationWillFinishLaunching:, - applicationDidFinishLaunching:
- (void)hide:(id)sender
See Also: - miniaturizeAll:, - unhide:, - unhideWithoutActivation, - applicationDidHide:, - applicationWillHide:
- (BOOL)isActive
YES
if
this is the active application, NO
otherwise.See Also: - activateIgnoringOtherApps:, - deactivate
- (BOOL)isHidden
YES
if
the application is hidden, NO
otherwise.See Also: - hide:, - unhide:, - unhideWithoutActivation
- (BOOL)isRunning
YES
if
the main event loop is running, NO
otherwise. NO
means
the stop: method was invoked. See Also: - run, - terminate:
- (NSWindow *)keyWindow
nil
if there is no key window,
if the application's nib file hasn't finished loading yet, or
if the key window belongs to another application. See Also: - mainWindow, - isKeyWindow (NSWindow)
- (NSMenu *)mainMenu
See Also: - setMainMenu:
- (NSWindow *)mainWindow
nil
if there is no
main window, if the application's nib file hasn't finished loading,
if the main window belongs to another application, or if the application is
hidden.See Also: - keyWindow, - isMainWindow (NSWindow)
- (NSWindow *)makeWindowsPerform:(SEL)aSelector
inOrder:(BOOL)flag
nil
. Returns
that NSWindow, or nil
if all NSWindows
returned nil
for aSelector. If flag is YES
,
the NSWindows receive the aSelector message
in the front-to-back order in which they appear in the Window Server's
window list. If flag is NO
,
NSWindows receive the message in the order they appear in NSApp
's
window list. This order is unspecified.
The method designated by aSelector can't take any arguments.
See Also: - sendAction:to:from:, - tryToPerform:with:, - windows
- (void)miniaturizeAll:(id)sender
See Also: - hide:
- (NSWindow *)modalWindow
nil
.- (NSEvent *)nextEventMatchingMask:(unsigned
int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
dequeue:(BOOL)flag
nil
if no such event
is found before the expiration date. If flag is YES
,
the event is removed from the queue. See the method description
for discardEventsMatchingMask:beforeEvent: for
a list of the possible values for mask.NSLeftMouseDownMask
NSLeftMouseUpMask
NSRightMouseDownMask
NSRightMouseUpMask
NSMouseMovedMask
NSLeftMouseDraggedMask
NSRightMouseDraggedMask
NSMouseEnteredMask
NSMouseExitedMask
NSKeyDownMask
NSKeyUpMask
NSFlagsChangedMask
NSPeriodicMask
NSCursorUpdateMask
NSAnyEventMask
The mode argument
names an NSRunLoop mode that determines what other ports are listened
to and what timers may fire while NSApp
is
waiting for the event. The possible modes available in the Application
Kit are:
NSDefaultRunLoopMode
NSEventTrackingRunLoopMode
NSModalPanelRunLoopMode
NSConnectionReplyMode
Events that are skipped are left in the queue.
You can use
this method to short circuit normal event dispatching and get your
own events. For example, you may want to do this in response to
a mouse-down event in order to track the mouse while it's down.
In this case, you would set mask to
accept mouse-dragged or mouse-up events and use the NSEventTrackingRunLoopMode
.
See Also: - postEvent:atStart:, - run, - runModalForWindow:
- (void)orderFrontColorPanel:(id)sender
- (void)orderFrontStandardAboutPanel:(id)sender
nil
argument. See orderFrontStandardAboutPanelWithOptions: for
a description of what's displayed.- (void)orderFrontStandardAboutPanelWithOptions:(NSDictionary
*)optionsDictionary
The following are keys that can occur in optionsDictionary:
Credits
": An NSAttributedString
displayed in the info area of the panel. If not specified, this method
then looks for a file named "Credits.rtf
"
in the bundle returned by the NSBundle class method mainBundle.
If neither is found, the info area is left blank.ApplicationName
":
An NSString displayed as the application's name. If not specified,
this method then looks for the value of NSHumanReadableShortName
in
the localized version of Info.plist
.
If neither is found, this method uses [[NSProcessInfo
processInfo] processName]
.ApplicationIcon
":
An NSImage displayed as the application's icon. If not specified,
this method then looks for an image named "NSApplicationIcon
",
using [NSImage imageNamed:@"NSApplicationIcon"].
If neither is available, this method uses the generic application
icon.Version
": An NSString
with the build version number of the application ("58.4");
displayed as "(v58.4)". If not specified, obtain from
the NSBuildVersion
key in infoDictionary;
if not specified, leave blank (the "(v)" is not displayed).Copyright
": An NSString
with a line of copyright information. If not specified, this method
then looks for the value of NSHumanReadableCopyright
in
the localized version InfoDictionary. If neither is available, this
method leaves the space blank.ApplicationVersion
":
An NSString with as the application version ("Mac OS X",
"WebObjects 4.5", "AppleWorks 6", ...). If not
specified, obtain from the NSAppVersion
key
in Info.plist
. If neither
is available, the build version, if available, is printed alone,
as "Version 58.4".See Also: - orderFrontStandardAboutPanel:
- (void)postEvent:(NSEvent
*)anEvent
atStart:(BOOL)flag
YES
,
the event is added to the front of the queue, otherwise the event
is added to the back of the queue. See Also: - currentEvent, - sendEvent:
- (void)preventWindowOrdering
- (void)registerServicesMenuSendTypes:(NSArray
*)sendTypes
returnTypes:(NSArray *)returnTypes
NSApp
. See Also: - validRequestorForSendType:returnType:, - readSelectionFromPasteboard: (NSServicesRequests protocol), - writeSelectionToPasteboard:types: (NSServicesRequests protocol)
- (void)removeWindowsItem:(NSWindow
*)aWindow
See Also: - addWindowsItem:title:filename:, - changeWindowsItem:title:filename:
- (void)reportException:(NSException
*)anException
NSLog()
. This
method does not raise the exception. Use it inside of an exception
handler to record that the exception occurred.- (void)run
NSApp
using sendEvent:. Send
a run message as the last statement from main()
,
after the application's objects have been initialized.
See Also: - runModalForWindow:, - runModalSession:, - applicationDidFinishLaunching:
- (int)runModalForWindow:(NSWindow
*)aWindow
NSRunStoppedResponse
.
If abortModal is used, it returns the constant NSRunAbortedResponse
. This
method is functionally similar to the following:NSModalSession session = [NSApp beginModalSessionForWindow:theWindow]; for (;;) { if ([NSApp runModalSession:session] != NSRunContinuesResponse) break; } [NSApp endModalSession:session];
The window aWindow is placed on the screen and made key as a result of the runModalForWindow: message. Do not send NSWindow's makeKeyAndOrderFront: to aWindow.
See Also: - run, - runModalSession:
- (int)runModalSession:(NSModalSession)session
If
the modal session was not stopped, this method returns NSRunContinuesResponse
.
If stopModalwas invoked
as the result of event processing, NSRunStoppedResponse
is
returned. If stopModalWithCode: was
invoked, this method returns the value passed to stopModalWithCode:.
The NSAbortModalException raised by abortModal isn't caught, so abortModal will
not stop the loop.
The window is placed on the screen and made key as a result of the runModalSession: message. Do not send a separate makeKeyAndOrderFront: message.
See Also: - endModalSession:, - run
- (void)runPageLayout:(id)sender
- (BOOL)sendAction:(SEL)anAction
to:(id)aTarget
from:(id)sender
nil
, NSApp
looks
for an object that can respond to the message-that is, an object
that implements a method matching anAction.
It begins with the first responder of the key window. If the first
responder can't respond, it tries the first responder's next
responder and continues following next responder links up the responder
chain. If none of the objects in the key window's responder chain
can handle the message, NSApp
attempts
to send the message to the key window's delegate.If the
delegate doesn't respond and the main window is different from
the key window, NSApp
begins again
with the first responder in the main window. If objects in the main
window can't respond, NSApp
attempts
to send the message to the main window's delegate. If still no
object has responded, NSApp
tries
to handle the message itself. If NSApp
can't
respond, it attempts to send the message to its own delegate.
Returns YES
if
the action is successfully sent, otherwise returns NO
.
See Also: - targetForAction:, - tryToPerform:with:, - makeWindowsPerform:inOrder:
- (void)sendEvent:(NSEvent
*)anEvent
See Also: - currentEvent, - postEvent:atStart:
- (NSMenu *)servicesMenu
nil
if no Services
menu has been created.See Also: - setServicesMenu:
- (id)servicesProvider
See Also: - setServicesProvider:
- (void)setAppleMenu:(NSMenu
*)menu
- (void)setApplicationIconImage:(NSImage
*)anImage
See Also: - applicationIconImage
- (void)setDelegate:(id)anObject
See Also: - delegate
- (void)setMainMenu:(NSMenu
*)aMenu
See Also: - mainMenu
- (void)setServicesMenu:(NSMenu
*)aMenu
See Also: - servicesMenu
- (void)setServicesProvider:(id)aProvider
For more information on registering services, see the on-line document on Service.
See Also: - servicesProvider
- (void)setWindowsMenu:(NSMenu
*)aMenu
See Also: - windowsMenu
- (void)setWindowsNeedUpdate:(BOOL)flag
See Also: - updateWindows
- (void)showHelp:(id)sender
The
help file is typically an RTF
file
and is displayed using Edit, but the help file can be anything.
For example, Project Builder brings up a Digital Librarian bookshelf
in response to its Help command.
For more information on providing on-line help for your application, see the NSHelpManager class specification.
See Also: - activateContextHelpMode:
- (void)stop:(id)sender
main()
function.
A subsequent run message will restart the
loop.If this method is invoked during a modal event loop, it will break that loop but not the main event loop.
See Also: - runModalForWindow:, - runModalSession:, - terminate:
- (void)stopModal
NSRunStoppedResponse
.
This method will stop the loop only if it's executed by code responding
to an event. If you need to stop a runModalForWindow: loop from a method
registered with the current NSRunLoop (for example, a method repeatedly
invoked by an NSTimer object), use the abortModal method. See Also: - runModalSession:, - stopModalWithCode:
- (void)stopModalWithCode:(int)returnCode
See Also: - abortModal
- (id)targetForAction:(SEL)aSelector
See Also: - sendAction:to:from:, - tryToPerform:with:
- (id)targetForAction:(SEL)theAction
to:(id)theTarget
from:(id)sender
- (void)terminate:(id)sender
NO
,
control is returned to the main event loop, and the application
isn't terminated. Otherwise, this method posts an NSApplicationWillTerminateNotification to
the default notification center. Don't put final cleanup code
in your application's main()
function-it
will never be executed. If cleanup is necessary, have the delegate
respond to applicationWillTerminate: and
perform cleanup in that method. - (BOOL)tryToPerform:(SEL)aSelector
with:(id)anObject
YES
. Otherwise,
it returns NO
.See Also: - respondsToSelector: (NSObject)
- (void)unhide:(id)sender
See Also: - activateIgnoringOtherApps:, - hide:
- (void)unhideWithoutActivation
See Also: - activateIgnoringOtherApps:, - hide:, - applicationDidUnhide:, - applicationWillUnhide:
- (void)updateWindows
When this method begins, it posts an NSApplicationWillUpdateNotification to the default notification center. When it successfully completes, it posts an NSApplicationDidUpdateNotification.
See Also: - setWindowsNeedUpdate:, - applicationDidUpdate:, - applicationWillUpdate:
- (void)updateWindowsItem:(NSWindow
*)aWindow
See Also: - changeWindowsItem:title:filename:, - setDocumentEdited: (NSWindow)
- (id)validRequestorForSendType:(NSString
*)sendType
returnType:(NSString *)returnType
NSApp
is
typically the last item in the responder chain, so it usually only
receives this message if none of the current responders can send sendType data
and accept back returnType data. The
receiver passes this message on to its delegate if the delegate
can respond (and isn't an NSResponder with its own next responder).
If the delegate can't respond or returns nil
,
this method returns nil
.
If the delegate can find an object that can send sendType data
and accept back returnType data,
that object is returned.
See Also: - registerServicesMenuSendTypes:returnTypes:, - validRequestorForSendType:returnType: (NSResponder), - readSelectionFromPasteboard: (NSServicesRequests protocol), - writeSelectionToPasteboard:types: (NSServicesRequests protocol)
- (NSWindow *)windowWithWindowNumber:(int)windowNum
- (NSArray *)windows
- (NSMenu *)windowsMenu
nil
if
no Window menu has been created.See Also: - setWindowsMenu:
- (BOOL)application:(NSApplication
*)theApplication
openFile:(NSString *)filename
YES
if
the file is successfully opened, and NO
otherwise.
If the user started up the application by double-clicking a file,
the delegate receives the application:openFile: message
before receiving applicationDidFinishLaunching:.
( applicationWillFinishLaunching: is
sent before application:openFile:.)See Also: - application:openFileWithoutUI:, - application:openTempFile:, - applicationOpenUntitledFile:
- (BOOL)application:(NSApplication
*)sender
openFileWithoutUI:(NSString *)filename
YES
if
the file was successfully opened, NO
otherwise. See Also: - application:openFile:, - application:openTempFile:, - applicationOpenUntitledFile:, - application:printFile:
- (BOOL)application:(NSApplication
*)theApplication
openTempFile:(NSString *)filename
YES
if the file is successfully
opened, and NO
otherwise.By design, a file opened through this method is assumed to be temporary-it's the application's responsibility to remove the file at the appropriate time.
See Also: - application:openFile:, - application:openFileWithoutUI:, - applicationOpenUntitledFile:
- (BOOL)applicationOpenUntitledFile:(NSApplication
*)theApplication
YES
if
the file was successfully opened, NO
otherwise. See Also: - application:openFile:, - application:openFileWithoutUI:, - application:openTempFile:
- (BOOL)application:(NSApplication
*)theApplication
printFile:(NSString *)filename
-NSPrint
option.
Sent directly by theApplication to
the delegate. The method should attempt to print the file filename,
returning YES
if the file was successfully printed,
and NO
otherwise. The application
terminates (using the terminate: method)
after this method returns.
If at all possible, this
method should print the file without displaying the user interface.
For example, if you pass the -NSPrint
option
to the TextEdit application, TextEdit assumes you want to print
the entire contents of the specified file. However, if the application
opens more complex documents, you may want to display a panel that
lets the user choose exactly what they want to print.
See Also: - application:openFileWithoutUI:
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication
*)sender
NO
to prevent the application
from opening an untitled file; return YES
,
otherwise. Note that applicationOpenUntitledFile: is
invoked if this method returns YES
.- (BOOL)applicationShouldTerminate:(NSApplication
*)sender
NO
,
the application is not terminated, and control returns to the main
event loop. Return YES
to allow the
application to terminate.See Also: - terminate:, - applicationShouldTerminateAfterLastWindowClosed:, - applicationWillTerminate:
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication
*)theApplication
If this method returns NO
,
the application is not terminated, and control returns to the main
event loop. Return YES
to allow the
application to terminate. Note that applicationShouldTerminate: is invoked
if this method returns YES
.
See Also: - terminate:
- (void)applicationDidBecomeActive:(NSNotification
*)aNotification
See Also: - applicationDidFinishLaunching:, - applicationDidResignActive:, - applicationWillBecomeActive:
- (void)applicationDidFinishLaunching:(NSNotification
*)aNotification
See Also: - finishLaunching, - applicationDidBecomeActive:
- (void)applicationDidHide:(NSNotification
*)aNotification
See Also: - applicationWillHide:, - applicationDidUnhide:, - hide:
- (void)applicationDidResignActive:(NSNotification
*)aNotification
See Also: - applicationDidBecomeActive:, - applicationWillResignActive:
- (void)applicationDidUnhide:(NSNotification
*)aNotification
See Also: - applicationDidHide:, - applicationWillUnhide:, - unhide:
- (void)applicationDidUpdate:(NSNotification
*)aNotification
See Also: - applicationWillUpdate:, - updateWindows
- (void)applicationWillBecomeActive:(NSNotification
*)aNotification
See Also: - applicationDidBecomeActive:, - applicationWillFinishLaunching:, - applicationWillResignActive:
- (void)applicationWillFinishLaunching:(NSNotification
*)aNotification
See Also: - applicationDidFinishLaunching:, - applicationWillBecomeActive:, - finishLaunching
- (void)applicationWillHide:(NSNotification
*)aNotification
See Also: - applicationDidHide:, - hide:
- (void)applicationWillResignActive:(NSNotification
*)aNotification
See Also: - applicationWillBecomeActive:, - applicationDidResignActive:
- (void)applicationWillTerminate:(NSNotification
*)aNotification
applicationWillTerminate: does not get called for logout for power-off. See NSWorkspaceWillPowerOffNotification, which is sent for these events.
See Also: - applicationShouldTerminate:, - terminate:
- (void)applicationWillUnhide:(NSNotification
*)aNotification
See Also: - unhide:, - applicationDidUnhide:, - applicationWillHide:
- (void)applicationWillUpdate:(NSNotification
*)aNotification
See Also: - applicationDidUpdate:, - updateWindows
These notifications apply to NSApplication. See "Notifications" (page 1850) in NSWorkspace for additional, similar notifications.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
NSApp
.
YES
.
This notification contains a notification object but no userInfo dictionary.
The notification object is NSApp
.
NSApp
.
NSApp
.