I have an outlet collection of DayViews's which are custom UIView objects. In my 'ClientTaskVC' I want to be able to reference DayView and be able to reach in and get its UIElements, each DayView has a dayLabel, dateLabel and checkmarkImg. I'm not sure if putting all the labels/imageviews in outlet collections is a smart idea as it would be harder to track and it looks wrong. In my first image I've detailed how this would look in code as well as showing my View controller with all my views as reference.
What I tried to do was add the outlets to the actual DayView custom class for all the labels and image but when I connected the outlets it could only connect to one DayView and was not reusable for every single DayView object on the screen, I don't think the right approach is to create an outlet collection in the custom DayView class to reference each of the views labels either so now I'm not really sure how to approach this problem
Ideally what I want is to just have my outlet collection in 'ClientTaskVC':
@IBOutlet var dayViews: [DayView]!
and call its UIElements (ex: dayViews[i].dayLbl.text) like so:
for i in 0 ..< dayViews.count {
let date = Date().addingTimeInterval(TimeInterval(86400 * i))
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd"
// See how the dayViews label, 'dayLbl' is being referenced
dayViews[i].dayLbl.text = dateFormatter.string(from: date)
dayViews[i].dayLbl.textAlignment = .center
}
Any help on how to do this with outlet collections would be greatly appreciated. Thank you.