Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var filteredArray:NSArray = [] //to store filtered data
- func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
- let string1 = string
- let string2 = searchText.text
- var finalString = ""
- if string.characters.count > 0 { // if it was not delete character
- finalString = string2! + string1
- } else {
- if (string2?.characters.count)! > 0 {
- finalString = String(describing: string2?.characters.dropLast())
- }
- filteredArray(searchString: finalString)
- }
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement