From 1e25ec3d8461ae4cc85b46ec49525faf8263e3de Mon Sep 17 00:00:00 2001 From: Yichi Zhang Date: Sun, 5 Nov 2017 23:25:22 +0800 Subject: [PATCH 1/2] Update for Swift 3.2.2 & iOS 11 (Xcode 9.1) --- Source/StringScore.swift | 4 +- StringScoreDemo/AppDelegate.swift | 39 ++--------- StringScoreDemo/Base.lproj/Main.storyboard | 64 ++++++++++--------- .../CustomInputViewController.swift | 2 +- .../DemoSearchTableController.swift | 12 ++-- 5 files changed, 47 insertions(+), 74 deletions(-) diff --git a/Source/StringScore.swift b/Source/StringScore.swift index 311a60e..e0f3070 100644 --- a/Source/StringScore.swift +++ b/Source/StringScore.swift @@ -47,9 +47,9 @@ public extension String finalScore = 0.0, string = self, lString = string.lowercased(), - strLength = string.characters.count, + strLength = string.count, lWord = word.lowercased(), - wordLength = word.characters.count, + wordLength = word.count, idxOf: String.Index!, startAt = lString.startIndex, fuzzies = 1.0, diff --git a/StringScoreDemo/AppDelegate.swift b/StringScoreDemo/AppDelegate.swift index a7fbf20..3f1e375 100644 --- a/StringScoreDemo/AppDelegate.swift +++ b/StringScoreDemo/AppDelegate.swift @@ -8,41 +8,12 @@ import UIKit -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate -{ +@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool - { - // Override point for customization after application launch. + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + return true } - - func applicationWillResignActive(_ application: UIApplication) - { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) - { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) - { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) - { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) - { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } } diff --git a/StringScoreDemo/Base.lproj/Main.storyboard b/StringScoreDemo/Base.lproj/Main.storyboard index 784e666..99afb48 100644 --- a/StringScoreDemo/Base.lproj/Main.storyboard +++ b/StringScoreDemo/Base.lproj/Main.storyboard @@ -1,9 +1,13 @@ - - + + + + + - + + @@ -11,8 +15,7 @@ - - + @@ -32,16 +35,16 @@ - + - + - + @@ -49,43 +52,43 @@ - + - + @@ -153,8 +156,7 @@ - - + @@ -173,7 +175,7 @@ - + @@ -189,29 +191,29 @@ - + - + - + - + diff --git a/StringScoreDemo/CustomInputViewController.swift b/StringScoreDemo/CustomInputViewController.swift index 5bd5f97..63fbf6a 100644 --- a/StringScoreDemo/CustomInputViewController.swift +++ b/StringScoreDemo/CustomInputViewController.swift @@ -76,7 +76,7 @@ class CustomInputViewController: UIViewController, UITextViewDelegate func updateStringScore() { if let sourceText = sourceTextView.text, let searchText = searchTextField.text { - let score = sourceText.score(searchText, fuzziness: Double(fuzzinessSlider.value)) + let score = sourceText.score(word: searchText, fuzziness: Double(fuzzinessSlider.value)) resultLabel.text = score.yz_toString() } } diff --git a/StringScoreDemo/DemoSearchTableController.swift b/StringScoreDemo/DemoSearchTableController.swift index d8e84f9..9de6f60 100644 --- a/StringScoreDemo/DemoSearchTableController.swift +++ b/StringScoreDemo/DemoSearchTableController.swift @@ -58,8 +58,7 @@ class DemoSearchTableController: UITableViewController, UISearchBarDelegate, UIS override func viewDidLoad() { super.viewDidLoad() - - + resultsTableController = ResultsTableController() // We want to be the delegate for our filtered table so didSelectRowAtIndexPath(_:) is called for both tables. @@ -69,7 +68,10 @@ class DemoSearchTableController: UITableViewController, UISearchBarDelegate, UIS searchController = UISearchController(searchResultsController: resultsTableController) searchController.searchResultsUpdater = self searchController.searchBar.sizeToFit() - tableView.tableHeaderView = searchController.searchBar + + if #available(iOS 11.0, *) { + navigationItem.searchController = searchController + } searchController.delegate = self searchController.dimsBackgroundDuringPresentation = false // default is YES @@ -80,8 +82,6 @@ class DemoSearchTableController: UITableViewController, UISearchBarDelegate, UIS // hierarchy until it finds the root view controller or one that defines a presentation context. definesPresentationContext = true - - tableView.register(UITableViewCell.self, forCellReuseIdentifier: defaultCellReuseIdentifier) } @@ -119,7 +119,7 @@ class DemoSearchTableController: UITableViewController, UISearchBarDelegate, UIS if let searchText = searchController.searchBar.text { var resultArray: Array = Array() for name in dataSourceArray { - let score = name.score(searchText) + let score = name.score(word: searchText) let t = (name: name, score: score) resultArray.append(t) From 0420fb30cbdbd1916baea55a6fe7f5512be7a30c Mon Sep 17 00:00:00 2001 From: Yichi Zhang Date: Sun, 5 Nov 2017 23:28:07 +0800 Subject: [PATCH 2/2] Carthage - Update Nimble & Quick --- Cartfile.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 83bc29d..521e3f8 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Quick/Nimble" "v7.0.0" -github "Quick/Quick" "v1.1.0" +github "Quick/Nimble" "v7.0.2" +github "Quick/Quick" "v1.2.0"