From 602e05b45d033ccc900c99ca134fb3fcdbe64f80 Mon Sep 17 00:00:00 2001 From: Agus Cahyono Date: Sun, 14 Apr 2019 20:50:40 +0700 Subject: [PATCH 1/6] Update to swift 5.0 --- Pods/EPContactsPicker.swift | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Pods/EPContactsPicker.swift b/Pods/EPContactsPicker.swift index d4d333b..e5e5b47 100644 --- a/Pods/EPContactsPicker.swift +++ b/Pods/EPContactsPicker.swift @@ -75,11 +75,11 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS } func inititlizeBarButtons() { - let cancelButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.cancel, target: self, action: #selector(onTouchCancelButton)) + let cancelButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel, target: self, action: #selector(onTouchCancelButton)) self.navigationItem.leftBarButtonItem = cancelButton if multiSelectEnabled { - let doneButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.done, target: self, action: #selector(onTouchDoneButton)) + let doneButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.done, target: self, action: #selector(onTouchDoneButton)) self.navigationItem.rightBarButtonItem = doneButton } @@ -156,8 +156,8 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS let productName = Bundle.main.infoDictionary!["CFBundleName"]! - let alert = UIAlertController(title: "Unable to access contacts", message: "\(productName) does not have access to contacts. Kindly enable it in privacy settings ", preferredStyle: UIAlertControllerStyle.alert) - let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: { action in + let alert = UIAlertController(title: "Unable to access contacts", message: "\(productName) does not have access to contacts. Kindly enable it in privacy settings ", preferredStyle: UIAlertController.Style.alert) + let okAction = UIAlertAction(title: "Ok", style: UIAlertAction.Style.default, handler: { action in completion([], error) self.dismiss(animated: true, completion: { self.contactDelegate?.epContactPicker(self, didContactFetchFailed: error) @@ -216,6 +216,8 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS print(error.localizedDescription) } + @unknown default: + <#fatalError()#> } } @@ -253,7 +255,7 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS override open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! EPContactCell - cell.accessoryType = UITableViewCellAccessoryType.none + cell.accessoryType = UITableViewCell.AccessoryType.none //Convert CNContact to EPContact let contact: EPContact @@ -269,7 +271,7 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS } if multiSelectEnabled && selectedContacts.contains(where: { $0.contactId == contact.contactId }) { - cell.accessoryType = UITableViewCellAccessoryType.checkmark + cell.accessoryType = UITableViewCell.AccessoryType.checkmark } cell.updateContactsinUI(contact, indexPath: indexPath, subtitleType: subtitleCellValue) @@ -282,14 +284,14 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS let selectedContact = cell.contact! if multiSelectEnabled { //Keeps track of enable=ing and disabling contacts - if cell.accessoryType == UITableViewCellAccessoryType.checkmark { - cell.accessoryType = UITableViewCellAccessoryType.none + if cell.accessoryType == UITableViewCell.AccessoryType.checkmark { + cell.accessoryType = UITableViewCell.AccessoryType.none selectedContacts = selectedContacts.filter(){ return selectedContact.contactId != $0.contactId } } else { - cell.accessoryType = UITableViewCellAccessoryType.checkmark + cell.accessoryType = UITableViewCell.AccessoryType.checkmark selectedContacts.append(selectedContact) } } @@ -310,8 +312,8 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS override open func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { if resultSearchController.isActive { return 0 } - tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: UITableViewScrollPosition.top , animated: false) - return sortedContactKeys.index(of: title)! + tableView.scrollToRow(at: IndexPath(row: 0, section: index), at: UITableView.ScrollPosition.top , animated: false) + return sortedContactKeys.firstIndex(of: title)! } override open func sectionIndexTitles(for tableView: UITableView) -> [String]? { @@ -345,7 +347,7 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS if let searchText = resultSearchController.searchBar.text , searchController.isActive { let predicate: NSPredicate - if searchText.characters.count > 0 { + if searchText.count > 0 { predicate = CNContact.predicateForContacts(matchingName: searchText) } else { predicate = CNContact.predicateForContactsInContainer(withIdentifier: contactsStore!.defaultContainerIdentifier()) From abf1ccc3226e3170efbfed2992f6eb983c36d351 Mon Sep 17 00:00:00 2001 From: Agus Cahyono Date: Sun, 14 Apr 2019 20:51:15 +0700 Subject: [PATCH 2/6] Support to swift 5 --- Pods/EPContact.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pods/EPContact.swift b/Pods/EPContact.swift index 199f5bb..00d579a 100644 --- a/Pods/EPContact.swift +++ b/Pods/EPContact.swift @@ -70,11 +70,11 @@ open class EPContact { open func contactInitials() -> String { var initials = String() - if let firstNameFirstChar = firstName.characters.first { + if let firstNameFirstChar = firstName.first { initials.append(firstNameFirstChar) } - if let lastNameFirstChar = lastName.characters.first { + if let lastNameFirstChar = lastName.first { initials.append(lastNameFirstChar) } From e4e23c055a15d983bef0064722c35606948a827d Mon Sep 17 00:00:00 2001 From: Agus Cahyono Date: Sun, 14 Apr 2019 20:53:49 +0700 Subject: [PATCH 3/6] support swift 5 --- Pods/EPExtensions.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Pods/EPExtensions.swift b/Pods/EPExtensions.swift index c45eba9..78d6f85 100644 --- a/Pods/EPExtensions.swift +++ b/Pods/EPExtensions.swift @@ -12,13 +12,14 @@ import Foundation extension String { subscript(r: Range) -> String? { get { - let stringCount = self.characters.count as Int + let stringCount = self.count as Int if (stringCount < r.upperBound) || (stringCount < r.lowerBound) { return nil } - let startIndex = self.characters.index(self.startIndex, offsetBy: r.lowerBound) - let endIndex = self.characters.index(self.startIndex, offsetBy: r.upperBound - r.lowerBound) - return self[(startIndex ..< endIndex)] + let startIndex = self.index(self.startIndex, offsetBy: r.lowerBound) + let endIndex = self.index(self.startIndex, offsetBy: r.upperBound - r.lowerBound) +// return self[(startIndex ..< endIndex)] + return String(self[startIndex ..< endIndex]) } } From 6b8a92775f98b90078f1ef47516ebf16b4c3075b Mon Sep 17 00:00:00 2001 From: Agus Cahyono Date: Sun, 14 Apr 2019 20:54:24 +0700 Subject: [PATCH 4/6] support swift 5 --- Pods/EPContactsPicker.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pods/EPContactsPicker.swift b/Pods/EPContactsPicker.swift index e5e5b47..b62c649 100644 --- a/Pods/EPContactsPicker.swift +++ b/Pods/EPContactsPicker.swift @@ -328,13 +328,13 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS // MARK: - Button Actions - func onTouchCancelButton() { + @objc func onTouchCancelButton() { dismiss(animated: true, completion: { self.contactDelegate?.epContactPicker(self, didCancel: NSError(domain: "EPContactPickerErrorDomain", code: 2, userInfo: [ NSLocalizedDescriptionKey: "User Canceled Selection"])) }) } - func onTouchDoneButton() { + @objc func onTouchDoneButton() { dismiss(animated: true, completion: { self.contactDelegate?.epContactPicker(self, didSelectMultipleContacts: self.selectedContacts) }) From 86acdc9851ca8a3d9f6c77e160b43143eee26863 Mon Sep 17 00:00:00 2001 From: Agus Cahyono Date: Sun, 14 Apr 2019 20:54:58 +0700 Subject: [PATCH 5/6] support swift 5 --- Pods/EPContactCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pods/EPContactCell.swift b/Pods/EPContactCell.swift index 7944249..46094b5 100644 --- a/Pods/EPContactCell.swift +++ b/Pods/EPContactCell.swift @@ -22,7 +22,7 @@ class EPContactCell: UITableViewCell { super.awakeFromNib() // Initialization code - selectionStyle = UITableViewCellSelectionStyle.none + selectionStyle = UITableViewCell.SelectionStyle.none contactContainerView.layer.masksToBounds = true contactContainerView.layer.cornerRadius = contactContainerView.frame.size.width/2 } From dc9dac0ed0045163203bc2e0be1f47d73c4a6c41 Mon Sep 17 00:00:00 2001 From: Agus Cahyono Date: Sun, 14 Apr 2019 20:56:45 +0700 Subject: [PATCH 6/6] Update EPContactsPicker.swift --- Pods/EPContactsPicker.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pods/EPContactsPicker.swift b/Pods/EPContactsPicker.swift index b62c649..7d3530b 100644 --- a/Pods/EPContactsPicker.swift +++ b/Pods/EPContactsPicker.swift @@ -217,7 +217,7 @@ open class EPContactsPicker: UITableViewController, UISearchResultsUpdating, UIS } @unknown default: - <#fatalError()#> + print("Undefined error") } }