Customizing length of passwords (while adding passwords)

This commit is contained in:
Yishi Lin 2017-03-09 02:19:47 +08:00
parent d761dd1fc5
commit 07782bd662
6 changed files with 147 additions and 6 deletions

View file

@ -8,9 +8,15 @@
import UIKit
protocol FillPasswordTableViewCellDelegate {
func generatePassword() -> String
}
class FillPasswordTableViewCell: ContentTableViewCell {
@IBOutlet weak var contentTextField: UITextField!
var delegate: FillPasswordTableViewCellDelegate?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
@ -23,7 +29,7 @@ class FillPasswordTableViewCell: ContentTableViewCell {
}
@IBAction func generatePassword(_ sender: UIButton) {
let plainPassword = Utils.generatePassword(length: 16)
let plainPassword = self.delegate?.generatePassword() ?? Utils.generatePassword(length: 16)
contentTextField.attributedText = Utils.attributedPassword(plainPassword: plainPassword)
Utils.copyToPasteboard(textToCopy: plainPassword)
}