0
境界版本 - > 2.10如何篩選多個變量,其中之一是Swift中的日期?
斯威夫特版> 3
var uuid: String
var resolutionID: Int
var dateFrom: Date
...
我檢查了變量不是空。 我想:
realm.objects(DeviceDataRealm.self).filter("device.uuid == '\(uuid)' AND resolution.idResolution == \(resolutionID) AND time > \(dateFrom)")
它不工作...
我試着用NSPredicate
太:
let predicate = NSPredicate(format: "device.uuid = %@ AND resolution.idResolution = %@ AND time > %@", uuid, resolutionID, dateFrom as CVarArg)
realm.objects(DeviceDataRealm.self).filter(predicate)
它的工作原理只是沒了Date
變量:
realm.objects(DeviceDataRealm.self).filter("device.uuid == '\(uuid)' AND resolution.idResolution == \(resolutionID))
任何想法??
謝謝。
您是否真的在尋找過去或未來的日期?我認爲這只是你的比較運算符翻轉。 –