Answer the question
In order to leave comments, you need to log in
Divide an array of objects into sections and count?
Hi all!
There is a ProviderClass class, about 200 objects.
Please tell me how to calculate the number of lines in each section by the "grp" parameter. It’s impossible to count the number of lines in any way, the number of sections seems to have been calculated:
func numberOfSections(in tableView: UITableView) -> Int {
return Set(providers.map{$0.grp}).count
}
Answer the question
In order to leave comments, you need to log in
From your object, make some structures:
struct Element {
let id: String
let title: String
let isVisible: Bool
}
struct Group {
let id: String
let elements: [Element]
}
struct Provider {
let groups: [Group]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question