Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. // MARK : Filtering methods
  2. fileprivate func filter() {
  3.  
  4. resultsList = []
  5.  
  6. for i in 0 ..< dataList.count {
  7.  
  8. let item = dataList[i]
  9.  
  10. let cityFilterRange = (item.cityName as NSString).range(of: text!, options: .caseInsensitive)
  11. let countryFilterRange = (item.countryName as NSString).range(of: text!, options: .caseInsensitive)
  12.  
  13. if cityFilterRange.location != NSNotFound {
  14. item.attributedCityName = NSMutableAttributedString(string: item.cityName)
  15. item.attributedCountryName = NSMutableAttributedString(string: item.countryName)
  16.  
  17. item.attributedCityName!.setAttributes([.font: UIFont.boldSystemFont(ofSize: 17)], range: cityFilterRange)
  18. if countryFilterRange.location != NSNotFound {
  19. item.attributedCountryName!.setAttributes([.font: UIFont.boldSystemFont(ofSize: 17)], range: countryFilterRange)
  20. }
  21. resultsList.append(item)
  22. }
  23. }
  24. tableView?.reloadData()
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement