你好我正在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