From f5f9fe505bb3b9b0ab7eb077f45903cfcf392c57 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Mon, 9 Oct 2017 22:14:48 -0700 Subject: [PATCH] Port to Swift 4 --- pass/Controllers/PasswordEditorTableViewController.swift | 2 +- passKit/Models/Password.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pass/Controllers/PasswordEditorTableViewController.swift b/pass/Controllers/PasswordEditorTableViewController.swift index ce72409..63cefe2 100644 --- a/pass/Controllers/PasswordEditorTableViewController.swift +++ b/pass/Controllers/PasswordEditorTableViewController.swift @@ -104,7 +104,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl let minimumLength = lengthSetting?.min ?? 0 let maximumLength = lengthSetting?.max ?? 0 var defaultLength = lengthSetting?.def ?? 0 - if let currentPasswordLength = (tableData[passwordSection][0][PasswordEditorCellKey.content] as? String)?.characters.count, + if let currentPasswordLength = (tableData[passwordSection][0][PasswordEditorCellKey.content] as? String)?.count, currentPasswordLength >= minimumLength, currentPasswordLength <= maximumLength { defaultLength = currentPasswordLength diff --git a/passKit/Models/Password.swift b/passKit/Models/Password.swift index b1e2426..cae9fee 100644 --- a/passKit/Models/Password.swift +++ b/passKit/Models/Password.swift @@ -84,7 +84,7 @@ public class Password { additions.removeAll() // split the plain text - let plainTextSplit = plainText.characters.split(maxSplits: 1, omittingEmptySubsequences: false) { + let plainTextSplit = plainText.split(maxSplits: 1, omittingEmptySubsequences: false) { $0 == "\n" || $0 == "\r\n" }.map(String.init) @@ -167,7 +167,7 @@ public class Password { public func getAdditionsPlainText() -> String { // lines starting from the second - let plainTextSplit = plainText.characters.split(maxSplits: 1, omittingEmptySubsequences: false) { + let plainTextSplit = plainText.split(maxSplits: 1, omittingEmptySubsequences: false) { $0 == "\n" || $0 == "\r\n" }.map(String.init) if plainTextSplit.count == 1 {