你好我正在swift上工作。我需要知道如何找到匹配确切字符串的结果。这里是我的代码NSPredicate与字符串完全匹配
let userID: String = String(sender.tag)
// Create a Predicate with mapping to trip_id
let filterByRequest: NSPredicate = NSPredicate(format: "%K.%K CONTAINS[c] %@", "ProductRequest", "user_id", userID)
// Filter your main array with predicate, resulting array will have filtered objects
let filteredArray: [AnyObject] = self.array.filteredArrayUsingPredicate(filterByRequest)
的问题是,如果用户ID是69它显示了用户id为69,6的结果,和9
我GOOGLE了,但我找到一些答案关闭我的问题,但他们都在客观C.
因为你使用CONTAINS [C ] ..意味着如果有任何字符在该字段中,那么你得到那个 –
是的我应该使用什么呢?@EICaptain – hellosheikh