15. State
ready → executing → finished
• ready
The isReady property contains the value true when the operation is ready to
execute now or false if there are still unfinished operations on which it is
dependent.
• executing
The isExecuting property must report the value true if the operation is working
on its task or false if it is not.
• finished
The isFinished key path lets clients know that an operation finished its task
successfully or was cancelled and is exiting.
• cancelled
The isCancelled key path lets clients know that the cancellation of an
operation was requested.
16. Cancelation
Once you add an operation to a queue, the operation is out
of your hands. The queue takes over and handles the
scheduling of that task. However, if you decide later that
you do not want to execute the operation after all—
because the user pressed a cancel button in a progress
panel or quit the application, for example—you can cancel
the operation to prevent it from consuming CPU time
needlessly.
• [NSOperation cancel]
• [NSOperationQueue cancellAllOperations]
19. NSQualityOfService
• UserInteractive
Used for work directly involved in providing an interactive UI. For example,
processing control events or drawing to the screen.
• UserInitiated
Used for performing work that has been explicitly requested by the user, and for
which results must be immediately presented in order to allow for further user
interaction. For example, loading an email after a user has selected it in a message
list.
• Utility
Used for performing work which the user is unlikely to be immediately waiting for
the results. This work may have been requested by the user or initiated
automatically, and often operates at user-visible timescales using a non-modal
progress indicator. For example, periodic content updates or bulk file operations,
such as media import.
• Background
Used for work that is not user initiated or visible. In general, a user is unaware
that this work is even happening. For example, pre-fetching content, search
indexing, backups, or syncing of data with external systems.
• Default
Indicates no explicit quality of service information. Whenever possible, an
appropriate quality of service is determined from available sources.