Вот как выглядит мой класс:
class Card : Object {
@objc dynamic var tags: String = ""
@objc dynamic var set_id: String = ""
}
Я хочу вернуть количество тегов из всех Карт с переадресованными set_id .
Вот метод:
func totalTags() -> String {
var tagCounter: Int = 0
let realm = try? Realm()
let totalCards = realm!.objects(Card.self).filter("set_id = '\(setId)'") //all Cards with selected set_id, set_id is global var.
for card in 0...totalCards.count {
//every 'card' has tags, but there there can me more tags,
//like : tags="one,twitter,world,Europe"...
//And I want to count all of them for every 'card'
let result = realm.objects(Card.self).filter() //How to filter?
tagCounter += //what? result.count or something?
}
return String(tagCounter)
}