Skip to content

Commit 5b11336

Browse files
added singleton
1 parent e991dcc commit 5b11336

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ios/Classes/SwiftDeviceCalendarPlugin.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ extension String {
2323
}
2424
}
2525

26+
fileprivate class SingleEventStore {
27+
public let eventStore: EKEventStore
28+
29+
public static let shared = SingleEventStore()
30+
31+
private init() {
32+
eventStore = EKEventStore()
33+
}
34+
}
35+
2636
public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin, EKEventViewDelegate, UINavigationControllerDelegate {
2737
struct DeviceCalendar: Codable {
2838
let id: String
@@ -102,7 +112,7 @@ public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin, EKEventViewDele
102112
let calendarNotFoundErrorMessageFormat = "The calendar with the ID %@ could not be found"
103113
let calendarReadOnlyErrorMessageFormat = "Calendar with ID %@ is read-only"
104114
let eventNotFoundErrorMessageFormat = "The event with the ID %@ could not be found"
105-
let eventStore = EKEventStore()
115+
let eventStore = SingleEventStore.shared.eventStore
106116
let requestPermissionsMethod = "requestPermissions"
107117
let hasPermissionsMethod = "hasPermissions"
108118
let retrieveCalendarsMethod = "retrieveCalendars"

0 commit comments

Comments
 (0)