Fix the "clearing passwords in 45s" function

- Copied passwords in the extension are not cleaned.
This commit is contained in:
Yishi Lin 2017-07-27 23:56:24 +08:00
parent f86a5eee65
commit a4efe57db9
7 changed files with 66 additions and 13 deletions

View file

@ -94,17 +94,11 @@ public class Utils {
print(error)
}
}
public static func copyToPasteboard(textToCopy: String?, expirationTime: Double = 45) {
public static func copyToPasteboard(textToCopy: String?) {
guard textToCopy != nil else {
return
}
UIPasteboard.general.string = textToCopy
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + expirationTime) {
let pasteboardString: String? = UIPasteboard.general.string
if textToCopy == pasteboardString {
UIPasteboard.general.string = ""
}
}
}
public static func attributedPassword(plainPassword: String) -> NSAttributedString{
let attributedPassword = NSMutableAttributedString.init(string: plainPassword)