daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top