Reputation: 31
I've seen that in Swift was so easy and fast to use... Right now can't find anything similar in swiftUI, i tried searching for EventKit but with 0 results.
Upvotes: 3
Views: 5758
Reputation: 1782
What you're trying to accomplish is a data operation done using the Swift language. SwiftUI is a framework for creating user interfaces. Generally, you want to separate your business logic (backend code like storing and editing data) with your UI logic (which is a visual representation of your data).
For your question, you would want to create a separate class that can add/remove data from Calendar. While it's a bit too much code to discuss in a StackOverflow post, you can refer to a couple of documents to get started:
Apple's EventKit Documentation
This link shared by bartonstanley is also useful:
Add Event to Calendar iOS Tutorial
Once you have created a class that can manage calendar information, you should either instantiate it and create it in the view you need, or use the Singleton model. This way, you don't have a SwiftUI view with 100+ lines of EventKit-related code that doesn't involve the UI.
I hope this helps!
Upvotes: 1
Reputation: 29
I think there is no build-in component for calendar in swiftUI but you try eny other third-party calendar controller for swiftUI like: https://iosexample.com/swiftui-simple-calendar-date-picker-for-ios/ or https://iosexample.com/tag/calendars/
Upvotes: 1