【发布时间】:2016-04-18 20:59:32
【问题描述】:
您好,我正在尝试过滤我的联系人,在模拟器 xcode 中一切正常,但是当我在 iPhone 上尝试时,我遇到了正则表达式谓词的问题。有什么建议么 ?。非常感谢。
func updateSearchResultsForSearchController(searchController: UISearchController) {
self.filteredContacs.removeAll(keepCapacity: false)
let searchPredcate = NSPredicate(format: "givenName contains[c] %@ OR familyName contains[c] %@",searchController.searchBar.text!)
let array = (self.contacts as NSArray).filteredArrayUsingPredicate(searchPredcate)
self.filteredContacs = array as! [CNContact]
self.tableViewContacts.reloadData()
}
【问题讨论】: