         butterflyViewController?.delegate = self
         butterflyViewController?.image = screenshot
         
-        var presented = UIApplication.sharedApplication().keyWindow?.rootViewController
+        var presented = UIApplication.shared.keyWindow?.rootViewController
         
         while let vc = presented?.presentedViewController {
             presented = vc
         }
         
         let nav = UINavigationController.init(rootViewController: butterflyViewController!)
-        nav.modalTransitionStyle = .CrossDissolve
+        nav.modalTransitionStyle = .crossDissolve
         
-        if presented?.isKindOfClass(UINavigationController) == true {
+        if presented?.isKind(of: UINavigationController.self) == true {
             let rootvc: UIViewController = (presented as! UINavigationController).viewControllers[0] 
-            if rootvc.isKindOfClass(ButterflyViewController) == false {
-                presented?.presentViewController(nav, animated: true, completion: nil)
+            if rootvc.isKind(of: ButterflyViewController.self) == false {
+                presented?.present(nav, animated: true, completion: nil)
             }
-        } else if presented?.isKindOfClass(ButterflyViewController) == false {
-            presented?.presentViewController(nav, animated: true, completion: nil)
+        } else if presented?.isKind(of: ButterflyViewController.self) == false {
+            presented?.present(nav, animated: true, completion: nil)
         }
     }
     
-    private func currentDate() -> String! {
-        let sec = NSDate().timeIntervalSinceNow
-        let currentDate = NSDate(timeIntervalSinceNow: sec)
+    fileprivate func currentDate() -> String! {
+        let sec = Date().timeIntervalSinceNow
+        let currentDate = Date(timeIntervalSinceNow: sec)
         
-        let dateFormatter = NSDateFormatter()
+        let dateFormatter = DateFormatter()
         dateFormatter.dateFormat = "yyyy/MM/dd HH/mm/ss"
-        let string = dateFormatter.stringFromDate(currentDate)
+        let string = dateFormatter.string(from: currentDate)
         return string
     }
     

    
    /// Register and start listening shake event.
    /// Register this method in AppDelegate will listen all motions during the whole application's life cycle.
    public func startListeningShake() {
        NSNotificationCenter.defaultCenter().addObserver(
            self,
            selector: #selector(handleShake),
            name: Notification.ButterflyDidShakingNotification,
            object: nil)
        isListeningShake = true
    }


///  Main manager class of Butterfly

open class ButterflyManager: NSObject {
    
    /// You can access instance variable `imageWillUpload` directly.
    open var imageWillUpload: UIImage? {
        return self.butterflyViewController?.imageWillUpload
    }
    
    /// Or instance variable `textWillUploader`.
    open var textWillUpload: String? {
        return self.butterflyViewController?.textWillUpload
    }
    
    /// Manager is listening shake event or not.
    open var isListeningShake: Bool?
    
    /// Shared manager used by the extension across Butterfly.
    open class var sharedManager: ButterflyManager {
        return instance
    }
    
