So I have this Array of EKEvent,
var events: [EKEvent] { get }
Where I load the users calender event without any problem, the probem comes when I use my Foreach to try and acess the data:
ForEach(viewModel.events, id: \.eventIdentifier ) { event in
HStack {
RoundedRectangle(cornerRadius: 25, style: .continuous)
.fill(Color(event.calendar.cgColor))
.frame(width: 4, height: 20)
VStack {
Text(event.title)
Using this I can acess some of the parameters inside events, like title, calender ect. But I get error if I try to acess startDate or endDate, saying there is no such parameter inside EKCalenderItem. If i use print(event) I get:
EKEvent <0x600001508780>
{
EKEvent <0x600001508780>
{ title = Daddade;
location = (null);
calendar = EKCalendar <0x6000031fb840> {title = Calendar; type = Local; allowsModify = YES; color = #1BADF8;};
alarms = (null);
URL = ;
lastModified = 2021-04-04 21:18:28 +0000;
startTimeZone = Europe/Stockholm (GMT+2) offset 7200 (Daylight);
endTimeZone = Europe/Stockholm (GMT+2) offset 7200 (Daylight)
};
location = (null);
structuredLocation = (null);
startDate = 2021-04-04 15:45:00 +0000;
endDate = 2021-04-04 16:45:00 +0000;
allDay = 0;
floating = 0;
recurrence = (null);
travelTime = (null);
startLocation = (null);
};
I suspect it has something to do with my foreach and the id, anyone got any deas how do acess, startDate?