Post

Replies

Boosts

Views

Activity

Reply to How to sum the same category total in SwiftUI?
Thank you sir, i tried it again but i got this error like below: let newArray = expensesData.filter {format(date: $0.date) == format(date: self.currentDate)}         let expenseArray = newArray.filter {$0.type == "Expense"}          //        self.sortedByExpense = expenseArray.sorted(by: {$0.amount > $1.amount})                  var icons: [String] = []         for i in expenseArray {             icons.append(i.expenseIcon)         }         print(icons)         var sums: [String] = []         for i in icons {             sums[i] = expenseArray.filter{$0.expenseIcon == i}.reduce(0){sum, item in sum + item.amount} //No 'reduce' candidates produce the expected contextual result type 'String' //No exact matches in call to subscript          }
Feb ’22