         view.endEditing(true)
         let updatedEnvironment = environments[picker.selectedRowInComponent(0)]
         AppNetworkState.currentAppState = updatedEnvironment
-        closeSwitcher()
+        delegate?.closeEnvironmentSwitcher(true)
     }
     
     @IBAction func cancelSwitch(sender: AnyObject) {
-        closeSwitcher()
+        delegate?.closeEnvironmentSwitcher(false)
     }
     
 }

    }
    
}


// MARK: - Private functions

private extension EnvironmentSwitcherViewController {
    
    func closeSwitcher() {
        presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
    }
    
}

import NetworkStack
import UIKit

public protocol EnvironmentSwitcherDelegate {
    func closeEnvironmentSwitcher(appNetworkStateChanged: Bool)
}

public class EnvironmentSwitcherViewController: UIViewController {
    
    // MARK: - Public properties
    
    public var delegate: EnvironmentSwitcherDelegate?
    public var environments = [AppNetworkState]()

    
