---
title: "#192: Being a Good Low Power Mode Citizen 🔋"
url: https://littlebitesofcocoa.com/192-being-a-good-low-power-mode-citizen
author: Jake Marsh
date: 2016-02-16
published: 2016-02-16
topics: ["UIKit"]
description: "Low Power Mode debuted in iOS 9. It's a great way to get another hour or two of use out of a device. When Apple first introduced this functionality, they..."
---

# #192: Being a Good Low Power Mode Citizen 🔋

By Jake Marsh, February 16, 2016. HTML: https://littlebitesofcocoa.com/192-being-a-good-low-power-mode-citizen

_Low Power Mode_ debuted in **iOS 9**. It's a great way to get another hour or two of use out of a device.

When Apple first introduced this functionality, they touted how the feature turns of <i>lots</i> of little things that contribute to the battery savings. 

It turns out we can actually provide these same savings in our own **apps**. Today we'll learn how. Let's get started:

The first way we'll interact with _Low Power Mode_ is through a property on **NSProcessInfo**.

Here we're working on **app** that displays **animated GIFs**. When the user stops scrolling, we automatically begin looping the **GIF**. However, if the user has _Low Power Mode_ enabled, we'll save a few **CPU/GPU** cycles by requiring the user to tap to start the animation:

``` swift
func userStoppedScrolling() {
  guard NSProcessInfo.processInfo().lowPowerModeEnabled == false else { return }
  gifView.beginPlaying()
}
```

We'll finish up by registering for this **NSNotification**:

``` swift
NSNotificationCenter.defaultCenter()
  .addObserver(self, 
    selector: "lowPowerModeChanged:", 
    name: NSProcessInfoPowerStateDidChangeNotification, 
    object: nil
  )
```

Then, inside `lowPowerModeChanged`, we can check with **NSProcessInfo** again. Now when a user returns to our app, we'll start/stop visible **GIFs** based on the _Low Power Mode_ state. Neat!
