 
 private let accountOrderKey = "persistentRefs"
 
-class AccountsViewController: UITableViewController {
+class AccountsViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
     @IBOutlet weak var emptyView: UIView!
 
     private let keychain = Keychain()
     private var accounts = [Account]()
+    private let qrImporter = UIImagePickerController()
+
     private lazy var searchController = makeSearchController()
     private lazy var addAccountAlertController = makeAddAccountAlertController()
 

            tableView.separatorStyle = .singleLine
            navigationItem.leftBarButtonItem = editButtonItem
        }
    }

    // MARK: UITableViewDataSource


    private func makeAddAccountAlertController() -> UIAlertController {
        let title = "Add Account"
        let message = "Add an account by scanning a QR code, importing a QR image, or entering a secret manually."
        let alertController = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)

        let scanQRCode = UIAlertAction(title: "Scan QR Code", style: .default) { [unowned self] _ in
            self.performSegue(withIdentifier: "ScanSegue", sender: self)
        }
        
        let importQRCode = UIAlertAction(title: "Import QR Image", style: .default) { [unowned self] _ in
            self.qrImporter.allowsEditing = false
            self.qrImporter.sourceType = .photoLibrary
                
            self.present(self.qrImporter, animated: true, completion: nil)
        }

        let enterManually = UIAlertAction(title: "Enter Manually", style: .default) { [unowned self] _ in
            self.performSegue(withIdentifier: "EnterManuallySegue", sender: self)
