Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MARK : Filtering methods
- fileprivate func filter() {
- resultsList = []
- for i in 0 ..< dataList.count {
- let item = dataList[i]
- let cityFilterRange = (item.cityName as NSString).range(of: text!, options: .caseInsensitive)
- let countryFilterRange = (item.countryName as NSString).range(of: text!, options: .caseInsensitive)
- if cityFilterRange.location != NSNotFound {
- item.attributedCityName = NSMutableAttributedString(string: item.cityName)
- item.attributedCountryName = NSMutableAttributedString(string: item.countryName)
- item.attributedCityName!.setAttributes([.font: UIFont.boldSystemFont(ofSize: 17)], range: cityFilterRange)
- if countryFilterRange.location != NSNotFound {
- item.attributedCountryName!.setAttributes([.font: UIFont.boldSystemFont(ofSize: 17)], range: countryFilterRange)
- }
- resultsList.append(item)
- }
- }
- tableView?.reloadData()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement