             }
 
             // This is the view controller for the popup dialog
-            self.shareViewController = ShareViewController()
-            self.shareViewController.delegate = self
-            self.shareViewController.shareItem = shareItem
+            let shareController = ShareViewController()
+            shareController.delegate = self
+            shareController.shareItem = shareItem
+            self.shareViewController = shareController
 
-            self.embedController = EmbeddedNavController(isSearchMode: !shareItem.isUrlType(), parent: self, rootViewController: self.shareViewController)
+            self.embedController = EmbeddedNavController(isSearchMode: !shareItem.isUrlType(), parent: self, rootViewController: shareController)
         }
     }
 


@objc(InitialViewController)
class InitialViewController: UIViewController {
    var embedController: EmbeddedNavController!
    var shareViewController: ShareViewController!

    override func viewDidLoad() {
        UIDevice.current.beginGeneratingDeviceOrientationNotifications()

    // At startup, the extension may show an alert that it can't share. In this case for a better UI, rather than showing
    // 2 popup dialogs (the main one and then the alert), just show the alert.
    func hidePopupWhenShowingAlert() {
        embedController?.navigationController.view.alpha = 0
    }
}

