Hi, I need help. I work with this Realm database
There is a class Category:
class Category : Object {
@objc dynamic var name : String = ""
@objc dynamic var type : String = ""
convenience init(name: String, type: String) {
self.init()
self.name = name
self.type = type
}
}
I create an instance (an array of categories):
var categories: Results<Category>!
And then in ViewDidLoad:
categories = realm.objects(Category.self)
Now, when working with TableViewController, I need to return the number of rows in the table, and then assign the value of the category name to the desired Label on the StoryBoard. This is where the problem lies, since a category has its own type, I want the number of categories displayed on the screen, and their names of the type that I will indicate.
Those. For example, there are types of “Expense” and “Income”. When you click on the “Expense” button, 10 categories of this type are shown, and when you click on “Income”, the other 20 categories of this type are displayed.
And finally my question. How to call only those elements of the categories
array whose type is “Expense”?
thanks