Reputation: 3
I have a Realm object with property dateCreated:
class Category: Object {
@objc dynamic var name : String = ""
@objc dynamic var itemn : String = ""
@objc dynamic var dateCreated : String = ""
var parentCategory = LinkingObjects(fromType: Datee.self , property: "cetegories")
}
I want to be able to query all categories by var dateCreated in order to count them and create appropriate number or rows in my tableView.
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
}
Upvotes: 0
Views: 538
Reputation: 1630
When you say query all categories by dateCreated, I'm assuming you mean all categories with a non empty dateCreated string . You would do this as follows:
var datedCategoriesCount = realm.objects(Category.self).filter("dateCreated != ''").count
Upvotes: 1