From 23d56ec66a73b361ba9d4bdbbb74ad596d0bd786 Mon Sep 17 00:00:00 2001 From: Brendan Lee Date: Tue, 5 Sep 2017 17:29:29 -0400 Subject: [PATCH] Convert to swift4 (auto-convert option: minimize objc tags). Fix a compile error that arose from using an 'internal' class to retrieve a default value for a public function --- FileBrowser.xcodeproj/project.pbxproj | 16 ++++++++++------ FileBrowser/FileBrowser.swift | 8 +++++--- FileBrowser/WebviewPreviewViewContoller.swift | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/FileBrowser.xcodeproj/project.pbxproj b/FileBrowser.xcodeproj/project.pbxproj index b329c3f..72d2116 100644 --- a/FileBrowser.xcodeproj/project.pbxproj +++ b/FileBrowser.xcodeproj/project.pbxproj @@ -259,11 +259,11 @@ TargetAttributes = { 344169531C67812400B93D28 = { CreatedOnToolsVersion = 7.2.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 3441695D1C67812400B93D28 = { CreatedOnToolsVersion = 7.2.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; ProvisioningStyle = Manual; }; }; @@ -463,7 +463,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -482,7 +483,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowser; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -494,7 +496,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowserTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -506,7 +509,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.FileBrowserTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/FileBrowser/FileBrowser.swift b/FileBrowser/FileBrowser.swift index a424d92..aad61e3 100644 --- a/FileBrowser/FileBrowser.swift +++ b/FileBrowser/FileBrowser.swift @@ -48,12 +48,14 @@ open class FileBrowser: UINavigationController { /// - initialPath: NSURL filepath to containing directory. /// - allowEditing: Whether to allow editing. /// - showCancelButton: Whether to show the cancel button. - public convenience init(initialPath: URL = FileParser.sharedInstance.documentsURL(), allowEditing: Bool = false, showCancelButton: Bool = true) { - let fileListViewController = FileListViewController(initialPath: initialPath, showCancelButton: showCancelButton) + public convenience init(initialPath: URL? = nil, allowEditing: Bool = false, showCancelButton: Bool = true) { + + let validInitialPath = initialPath ?? FileParser.sharedInstance.documentsURL() + + let fileListViewController = FileListViewController(initialPath: validInitialPath, showCancelButton: showCancelButton) fileListViewController.allowEditing = allowEditing self.init(rootViewController: fileListViewController) self.view.backgroundColor = UIColor.white self.fileList = fileListViewController } - } diff --git a/FileBrowser/WebviewPreviewViewContoller.swift b/FileBrowser/WebviewPreviewViewContoller.swift index 0a4e43c..f1b40bc 100644 --- a/FileBrowser/WebviewPreviewViewContoller.swift +++ b/FileBrowser/WebviewPreviewViewContoller.swift @@ -39,7 +39,7 @@ class WebviewPreviewViewContoller: UIViewController { //MARK: Share - func shareFile(_ sender: UIBarButtonItem) { + @objc func shareFile(_ sender: UIBarButtonItem) { guard let file = file else { return }