Swift 2使用Predicate无法在我的过滤器上获得任何结果

时间:2016-06-28 09:48:10

标签: swift predicate

我做错了什么?

import UIKit
var values:NSMutableArray  = []
let url = NSURL(string: "URL")  // PHP JSON Result
let data = NSData(contentsOfURL: url!)
values = try! NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSMutableArray

var searchtext = "ROYAL"

let resultPredicate = NSPredicate(format: "SELF contains[cd] %@", searchtext)
let filteredCars = values.filteredArrayUsingPredicate(resultPredicate)

1 个答案:

答案 0 :(得分:-1)

像这样更改你的代码

select * 
from DataInizioGestione
where OtherFieldFK like = '2016%'

您需要添加要在其中过滤文字的let resultPredicate = NSPredicate(format: "SELF.Vendor contains[cd] %@ OR SELF.vendor contains[cd] %@ OR SELF.email contains[cd] %@", searchtext, searchtext, searchtext) let filteredCars = values.filteredArrayUsingPredicate(resultPredicate) 希望这会对你有所帮助。