Convert to Swift 4

- Will fix all warnings next.
This commit is contained in:
Yishi Lin 2017-09-23 16:29:03 +08:00
parent 7640d55317
commit 774f05eae0
17 changed files with 77 additions and 49 deletions

View file

@ -81,7 +81,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
}
}
func setNeedRefresh() {
@objc func setNeedRefresh() {
needRefresh = true
}
}

View file

@ -84,7 +84,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
}
}
func encryptInASCIIArmoredAction(_ sender: Any?) {
@objc func encryptInASCIIArmoredAction(_ sender: Any?) {
SharedDefaults[.encryptInArmored] = encryptInASCIIArmoredSwitch.isOn
}

View file

@ -42,7 +42,7 @@ class CommitLogsTableViewController: UITableViewController {
return cell
}
func updateCommitLogs() {
@objc func updateCommitLogs() {
commits = getCommitLogs()
tableView.reloadData()
}

View file

@ -153,37 +153,37 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
self.present(optionMenu, animated: true, completion: nil)
}
func tapHideUnknownSwitchDetailButton(_ sender: Any?) {
@objc func tapHideUnknownSwitchDetailButton(_ sender: Any?) {
let alertMessage = "Only \"key: value\" format in additional fields is supported. Unsupported fields will be given \"unknown\" keys. Turn on this switch to hide unsupported fields."
let alertTitle = "Hide Unknown Fields"
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)
}
func tapHideOTPSwitchDetailButton(_ sender: Any?) {
@objc func tapHideOTPSwitchDetailButton(_ sender: Any?) {
let keywordsString = Password.otpKeywords.joined(separator: ",")
let alertMessage = "Turn on this switch to hide the fields related to one time passwords (i.e., \(keywordsString))."
let alertTitle = "Hide One Time Password Fields"
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)
}
func hideUnknownSwitchAction(_ sender: Any?) {
@objc func hideUnknownSwitchAction(_ sender: Any?) {
SharedDefaults[.isHideUnknownOn] = hideUnknownSwitch.isOn
NotificationCenter.default.post(name: .passwordDetailDisplaySettingChanged, object: nil)
}
func hideOTPSwitchAction(_ sender: Any?) {
@objc func hideOTPSwitchAction(_ sender: Any?) {
SharedDefaults[.isHideOTPOn] = hideOTPSwitch.isOn
NotificationCenter.default.post(name: .passwordDetailDisplaySettingChanged, object: nil)
}
func rememberPassphraseSwitchAction(_ sender: Any?) {
@objc func rememberPassphraseSwitchAction(_ sender: Any?) {
SharedDefaults[.isRememberPassphraseOn] = rememberPassphraseSwitch.isOn
if rememberPassphraseSwitch.isOn == false {
passwordStore.pgpKeyPassphrase = nil
}
}
func showFolderSwitchAction(_ sender: Any?) {
@objc func showFolderSwitchAction(_ sender: Any?) {
SharedDefaults[.isShowFolderOn] = showFolderSwitch.isOn
NotificationCenter.default.post(name: .passwordDisplaySettingChanged, object: nil)
}

View file

@ -15,7 +15,7 @@ class OTPScannerController: QRScannerController {
var scannedOTP: String?
// MARK: - AVCaptureMetadataOutputObjectsDelegate Methods
override func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
if let metadataObj = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
supportedCodeTypes.contains(metadataObj.type),

View file

@ -47,7 +47,7 @@ class OpenSourceComponentsTableViewController: BasicStaticTableViewController {
super.viewDidLoad()
}
func actOnDetailDisclosureButton(_ sender: Any?) {
@objc func actOnDetailDisclosureButton(_ sender: Any?) {
if let link = sender as? String {
let svc = SFSafariViewController(url: URL(string: link)!, entersReaderIfAvailable: false)
self.present(svc, animated: true, completion: nil)

View file

@ -11,7 +11,7 @@ import SVProgressHUD
import passKit
fileprivate class PasswordsTableEntry : NSObject {
var title: String
@objc var title: String
var isDir: Bool
var passwordEntity: PasswordEntity?
init(title: String, isDir: Bool, passwordEntity: PasswordEntity?) {
@ -293,7 +293,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
}
}
func backAction(_ sender: Any?) {
@objc func backAction(_ sender: Any?) {
guard SharedDefaults[.isShowFolderOn] else { return }
var anim: CATransition? = transitionFromLeft
if parentPasswordEntity == nil {
@ -302,7 +302,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
reloadTableView(parent: parentPasswordEntity?.parent, anim: anim)
}
func longPressAction(_ gesture: UILongPressGestureRecognizer) {
@objc func longPressAction(_ gesture: UILongPressGestureRecognizer) {
if gesture.state == UIGestureRecognizerState.began {
let touchPoint = gesture.location(in: tableView)
if let indexPath = tableView.indexPathForRow(at: touchPoint) {
@ -412,7 +412,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
sections = newSections.filter {$0.entries.count > 0}
}
func actOnSearchNotification() {
@objc func actOnSearchNotification() {
searchController.searchBar.becomeFirstResponder()
}
@ -507,7 +507,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
reloadTableView(data: passwordsTableEntries, anim: anim)
}
func actOnReloadTableViewRelatedNotification() {
@objc func actOnReloadTableViewRelatedNotification() {
DispatchQueue.main.async { [weak weakSelf = self] in
guard let strongSelf = weakSelf else { return }
strongSelf.initPasswordsTableEntries(parent: nil)
@ -515,7 +515,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
}
}
func handleRefresh(_ syncControl: UIRefreshControl) {
@objc func handleRefresh(_ syncControl: UIRefreshControl) {
syncPasswords()
syncControl.endRefreshing()
}

View file

@ -24,7 +24,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg
var videoPreviewLayer: AVCaptureVideoPreviewLayer?
var qrCodeFrameView: UIView?
let supportedCodeTypes = [AVMetadataObjectTypeQRCode]
let supportedCodeTypes = [AVMetadataObject.ObjectType.qr]
var delegate: QRScannerControllerDelegate?
@ -32,11 +32,11 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg
super.viewDidLoad()
// Get an instance of the AVCaptureDevice class to initialize a device object and provide the video as the media type parameter.
let captureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
let captureDevice = AVCaptureDevice.default(for: AVMediaType.video)
do {
// Get an instance of the AVCaptureDeviceInput class using the previous device object.
let input = try AVCaptureDeviceInput(device: captureDevice)
let input = try AVCaptureDeviceInput(device: captureDevice!)
// Initialize the captureSession object.
captureSession = AVCaptureSession()
@ -53,8 +53,8 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg
captureMetadataOutput.metadataObjectTypes = supportedCodeTypes
// Initialize the video preview layer and add it as a sublayer to the viewPreview view's layer.
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
videoPreviewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!)
videoPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
videoPreviewLayer?.frame = view.layer.bounds
view.layer.addSublayer(videoPreviewLayer!)
@ -90,7 +90,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg
// MARK: - AVCaptureMetadataOutputObjectsDelegate Methods
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
func metadataOutput(captureOutput: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
if let metadataObj = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
supportedCodeTypes.contains(metadataObj.type),

View file

@ -191,7 +191,7 @@ class SettingsTableViewController: UITableViewController {
}
}
func actOnPasswordStoreErasedNotification() {
@objc func actOnPasswordStoreErasedNotification() {
setPGPKeyTableViewCellDetailText()
setPasswordRepositoryTableViewCellDetailText()
setPasscodeLockTouchIDCells()
@ -213,7 +213,7 @@ class SettingsTableViewController: UITableViewController {
tableView.deselectRow(at: indexPath, animated: true)
}
func touchIDSwitchAction(uiSwitch: UISwitch) {
@objc func touchIDSwitchAction(uiSwitch: UISwitch) {
if !passcodeLockConfig.repository.hasPasscode || !isTouchIDEnabled() {
// switch off
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {