Beginner programmer here.
I am trying to show two different color dots if there is a negative AND a positive transaction for that date.
Here is my code. It only shows one dot.
func calendar(_ calendar: FSCalendar, numberOfEventsFor date: Date) -> Int {
let incomeTransaction = realm.objects(Transaction.self).filter(positiveTransactionPredicate(date: date))
let expenseTransaction = realm.objects(Transaction.self).filter(negativeTransactionPredicate(date: date))
for _ in incomeTransaction {
return 1
}
for _ in expenseTransaction {
return 1
}
return 0
}
func calendar(_ calendar: FSCalendar, appearance: FSCalendarAppearance, eventDefaultColorsFor date: Date) -> [UIColor]? {
let incomeTransaction = realm.objects(Transaction.self).filter(positiveTransactionPredicate(date: date))
let expenseTransaction = realm.objects(Transaction.self).filter(negativeTransactionPredicate(date: date))
for _ in incomeTransaction {
return [UIColor(rgb: Constants.green)]
}
for _ in expenseTransaction {
return [UIColor(rgb: Constants.red)]
}
return nil
}
This code shows two dots, but they are the same color:
func calendar(_ calendar: FSCalendar, numberOfEventsFor date: Date) -> Int {
let incomeTransaction = realm.objects(Transaction.self).filter(positiveTransactionPredicate(date: date))
let expenseTransaction = realm.objects(Transaction.self).filter(negativeTransactionPredicate(date: date))
for _ in incomeTransaction {
return 2
}
for _ in expenseTransaction {
return 2
}
return 0
}
How do you tell the FSCalendar delegate methods to show two different color dots on a date?
Like This:
Thanks.