         }
         else {
             // Otherwise use iPhone style action sheet presentation.
-            let window = UIApplication.sharedApplication().delegate!.window as! UIWindow
+            // UIWindow hack: http://stackoverflow.com/a/28902549/300224
+            let window = (UIApplication.sharedApplication().delegate!.window ?? nil)! as UIWindow
             let topVC = topViewController(presentingViewController)
-            if window?.subviews.contains(topVC.view!) {
+            if window.subviews.contains(topVC.view!) {
                 actionSheet.showInView(topVC.view)
             }
             else {

extension FDTakeController : UIImagePickerControllerDelegate {
    public func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
        UIApplication.sharedApplication().statusBarHidden = true
        var mediaType: String = info[UIImagePickerControllerMediaType] as! String
        var imageToSave: UIImage
        // Handle a still image capture
        if mediaType == kUTTypeImage as String {

    
    private lazy var popover: UIPopoverController = {
        [unowned self] in
        return UIPopoverController(contentViewController: self.imagePicker)
    }()
    
    private var actionSheet: UIActionSheet? = nil
