I do not suppose there is a particular methodology in your case however you may observe it manually:
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
non-public let textField: UITextField = {
let textual content = UITextField()
textField.borderStyle = .roundedRect
textField.translatesAutoresizingMaskIntoConstraints = false
return tf
}()
non-public var previousText: String = ""
override func viewDidLoad() {
tremendous.viewDidLoad()
view.backgroundColor = .white
setupTextField()
}
non-public func setupTextField() {
view.addSubview(textField)
textField.delegate = self
textField.addTarget(self, motion: #selector(textFieldDidChange(_:)), for: .editingChanged)
NSLayoutConstraint.activate([
textField.centerXAnchor.constraint(equalTo: view.centerXAnchor),
textField.centerYAnchor.constraint(equalTo: view.centerYAnchor),
textField.widthAnchor.constraint(equalToConstant: 250),
textField.heightAnchor.constraint(equalToConstant: 40)
])
}
@objc non-public func textFieldDidChange(_ textField: UITextField) {
guard let newText = textField.textual content else { return }
if hasCombinedCharacters(earlier: previousText, present: newText) {
print("Обнаружено объединение символов!")
}
previousText = newText
}
non-public func hasCombinedCharacters(earlier: String, present: String) -> Bool {
let prevDecomposed = earlier.decomposedStringWithCanonicalMapping
let currDecomposed = present.decomposedStringWithCanonicalMapping
return prevDecomposed.rely == currDecomposed.rely
}
}