• available since iOS2.0, a very important class that provides essential information about the Environment (Process, Computer hardware, OS), but MORE IMPORTANTLY, it also manage activities (long-time-running tasks).
  • provides methods to access information about the current process. Each process has an agent (NSProcessInfo).
  • returns arguments, environment variables, host name, process name, operating system !


  1. Process information
  • arguments
  • environment
  • globallyUniqueString
  • processIdentifier
  • processName
  1. Computer information
  • processorCount
  • activeProcessorCount
  • physicalMemory
  • systemUptime
  1. Host information
  • hostName
  • operatingSystemVersionString
  • operatingSystemVersion
  • function: isOperatingSystemAtLeastVersion:

Data Types

struct NSOperatingSystemVersion

(majorVersion:int, minorVersion:int, patchVersion:int)

struct NSActivityOptions:

    1. IdleDisplaySleepDisabled
    2. IdleSystemSleepDisabled
    3. SuddenTerminationDisabled
    4. AutomaticTerminationDisabled
    5. UserInitiated
    6. UserInitiatedAllowingIdleSystemSleep
    7. Background
    8. LatencyCritical

+ Managing Activities: 

We can use methods to give hints to the system that your application has special requirements:
  • beginActivityWithOptions:reason:
  • endActivity:
  • performActivityWithOptions:reason:usingBlock:
  • performExpiringActivityWithReason:usingBlock:
Use activities when performing long-running operations !!! 2 categories:
  • User initiated: user explicitly started: exporting or downloading file – NSActivityUserInitiated
  • Background: not by user: autosaving, indexing, …
Special category: NSActivitiyLatencyCritical  – use for audio or video recording – which requires high priority!
If activities are synchronous inside an event callback on main thread -> no need to use this !
Also we can use this to control Automatic Termination:
  1. id activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityAutomaticTerminationDisabled reason:@"Good Reason"];
  2. // Perform some work.
  3. [[NSProcessInfo processInfo] endActivity:activity];
This API also provides mechanism to disable system-wide & display idle-sleep. So it’s important to end activities that disable sleep. 

Sudden Termination:

To log out or shut down more quickly, system may kill applications instead of requesting them to quit. We can use:
  • enableSuddenTermination: decrement counter
  • disableSuddenTermination: increment counter
When we start the app, counter = 1. If counter == 0 -> safely killable.
If we have  NSSupportsSuddenTermination = YES in application plist -> the app is killable right away (but still can disableSuddenTermination)
Disable Sudden Termination when: app usually have to do something before it terminates (saving), then we bracket these operations within disableSuddenTermination and enableSuddenTermination.
Some AppKit actually disable sudden termination for a time while performing saving operations:
  • NSUserDefaults temporarily disables sudden termination to prevent process killing when that default is written to disk.
Thermal State: app should reduce system usage at high thermal states: register for NSProcessInfoThermalStateDidChangeNotification
to handle it.