在我Xcode6.3下RealmSwift(0.92.3),我將如何境界日期查詢
// the Realm Object Definition
import RealmSwift
class NameEntry: Object {
dynamic var player = ""
dynamic var gameCompleted = false
dynamic var nrOfFinishedGames = 0
dynamic var date = NSDate()
}
目前的tableView查找對象(即目前的所有對象)的數量一樣如下:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let cnt = RLM_array?.objects(NameEntry).count {
return Int(cnt)
}
else {
return 0
}
}
第一個問題:如何查找具有日期條目的對象的數量,比方說,日期是15.06.2014? (即在RealmSwift-Object的特定日期之上的日期查詢 - 這是如何工作的?)。換句話說,上面的方法將如何找到具有所需日期範圍的對象的數量?
所有領域對象成的tableView的成功填充如下所示:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("NameCell") as! PlayersCustomTableViewCell
if let arry = RLM_array {
let entry = arry.objects(NameEntry)[indexPath.row] as NameEntry
cell.playerLabel.text = entry.player
cell.accessoryType = entry.gameCompleted ? .None : .None
return cell
}
else {
cell.textLabel!.text = ""
cell.accessoryType = .None
return cell
}
}
第二個問題:我如何將填補到的tableView只是具有特定日期(即例如RealmSwift對象僅填充日期再次爲15.06.2014以上的對象)。或者換句話說,上面的方法如何才能在tableView中填充所需的日期範圍?