Swift 3에서 filter () 메서드를 사용하고 있지만 문제가 발생하면 내 코드가 ....
filtered = arrayTag.filter(using: { (text) -> Bool in
//Access the title and sectors
let tmpTitle = text["tag_name"] as! String
let tmpSector = text["tag_id"] as! String
//Create a range for both
let range1 = tmpTitle.range(of: searchText, options: NSString.CompareOptions.caseInsensitive)
let range2 = tmpSector.range(of: searchText, options: NSString.CompareOptions.caseInsensitive)
print("search result \(text)")
//Return true if either match
return range1 != nil || range2 != nil
})
위의 문제에 대한 해결책은 다음과 같습니다.
let tmpTitle = (text as! NSDictionary)["tag_name"] as? String
캐스트 텍스트 as! NSDictionary
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다