Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event has no starDate or endDate #343

Closed
3 tasks done
R35Master opened this issue Aug 15, 2022 · 4 comments
Closed
3 tasks done

Event has no starDate or endDate #343

R35Master opened this issue Aug 15, 2022 · 4 comments
Labels

Comments

@R35Master
Copy link

New Issue Checklist

Issue Description

Hi,

I was following the latest guide on youtube to implement CK to my app. At the very beginning I had the issue "Value of type 'Event' has no member 'startDate'"

and I checked the document(EVENT.SWIFT) with option key > go to document and literally I couldnt find startDate or endDate.
Screen Shot 2022-08-15 at 21 18 18

Any ideas?

Code I'm using with CalendarKit
    override func eventsForDate(_ date: Date) -> [EventDescriptor] {
        
        let startDate = date
        
        var oneDayComponents = DateComponents()
        oneDayComponents.day = 1
        
        let endDate = calendar.date(byAdding: oneDayComponents, to: startDate)!
        
        let predicate = eventStore.predicateForEvents(withStart: startDate, end: endDate, calendars: nil)
        
        let eventKitEvents = eventStore.events(matching: predicate)
        
        let calenderKitEvents = eventKitEvents.map { ekEvent -> Event in
            let ckEvent = Event()
       //    ckEvent.startDate = ekEvent.startDate <<<<
       //    ckEvent.endDate = ekEvent.endDate <<<<
            ckEvent.isAllDay = ekEvent.isAllDay
            ckEvent.text = ekEvent.title
            if let eventColor = ekEvent.calendar.cgColor {
                ckEvent.color = UIColor(cgColor: eventColor)
            }
            return ckEvent
        }
        return calenderKitEvents
    }
}

Result I am trying to achieve

@R35Master R35Master added the bug label Aug 15, 2022
@R35Master
Copy link
Author

@richardtop Hi mate, could you please guide me what to do hear?

@richardtop
Copy link
Owner

richardtop commented Aug 15, 2022

Hi, the API has changed here: https://github.com/richardtop/CalendarKit/releases/tag/1.1.0

Now the API requires to set DateInterval: https://developer.apple.com/documentation/foundation/dateinterval

Video & discussion of the change with example: https://www.youtube.com/watch?v=rmO0TT3mQIM

Video tutorial of how to change the app (section "Refactoring the demo app"): https://youtu.be/rmO0TT3mQIM?t=1360

The latest version of the EKWrapper.swift with the relevant line highlighted: https://github.com/richardtop/CalendarApp/blob/master/Calendar/EKWrapper.swift#L13

@richardtop richardtop reopened this Aug 15, 2022
@richardtop richardtop added question and removed bug labels Aug 15, 2022
@R35Master
Copy link
Author

Much appreciated @richardtop

@richardtop
Copy link
Owner

In case you don't have further questions, feel free to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants