From fdbefeefa07db8a8f93cc783506faaa008ade34d Mon Sep 17 00:00:00 2001 From: Jess Date: Sun, 3 Sep 2017 07:49:58 +0900 Subject: [PATCH 1/5] update dates Change loadEvents() start and end dates to be based off of the current date rather than hardcoded to 2016. --- EventTracker/EventsViewController.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/EventTracker/EventsViewController.swift b/EventTracker/EventsViewController.swift index 0e81f92..cd03c8e 100644 --- a/EventTracker/EventsViewController.swift +++ b/EventTracker/EventsViewController.swift @@ -25,15 +25,13 @@ class EventsViewController: UIViewController, UITableViewDataSource, EventAddedD } func loadEvents() { - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "yyyy-MM-dd" - let startDate = dateFormatter.date(from: "2016-01-01") - let endDate = dateFormatter.date(from: "2016-12-31") - - if let startDate = startDate, let endDate = endDate { + let startDate = Date() // now + let endDate = Calendar.current.date(byAdding: .year, value: 1, to: Date()) + + if let endDate = endDate { let eventStore = EKEventStore() - + let eventsPredicate = eventStore.predicateForEvents(withStart: startDate, end: endDate, calendars: [calendar]) self.events = eventStore.events(matching: eventsPredicate).sorted { From 7e69aa0501636413f51489e956d65d96cfebaac5 Mon Sep 17 00:00:00 2001 From: Jess Date: Mon, 4 Sep 2017 12:17:55 +0900 Subject: [PATCH 2/5] add view in Calendar install JTAppleCalendar pod customize view to show events from selected calendar in a calendar view --- EventTracker.xcodeproj/project.pbxproj | 96 +- .../contents.xcworkspacedata | 10 + EventTracker/AddEventViewController.swift | 29 +- EventTracker/Base.lproj/Main.storyboard | 287 ++++- EventTracker/CalViewController.swift | 250 ++++ EventTracker/CustomCell.swift | 34 + EventTracker/EventsViewController.swift | 32 +- EventTracker/HeaderView.swift | 22 + EventTracker/Info.plist | 2 + EventTracker/SegueIdentifiers.swift | 3 +- Podfile | 7 + Podfile.lock | 12 + Pods/JTAppleCalendar/LICENSE | 19 + Pods/JTAppleCalendar/README.md | 144 +++ .../Sources/CalendarEnums.swift | 111 ++ .../Sources/CalendarStructs.swift | 390 +++++++ .../GlobalFunctionsAndExtensions.swift | 73 ++ .../JTAppleCalendarDelegateProtocol.swift | 49 + .../Sources/JTAppleCalendarLayout.swift | 729 ++++++++++++ .../JTAppleCalendarLayoutProtocol.swift | 36 + .../Sources/JTAppleCalendarVariables.swift | 92 ++ .../Sources/JTAppleCalendarView.swift | 1027 +++++++++++++++++ .../JTAppleCalendar/Sources/JTAppleCell.swift | 47 + .../JTAppleCollectionReusableView.swift | 37 + .../Sources/JTCalendarProtocols.swift | 130 +++ .../Sources/UICollectionViewDelegates.swift | 169 +++ .../Sources/UIScrollViewDelegates.swift | 248 ++++ .../Sources/UserInteractionFunctions.swift | 573 +++++++++ Pods/Manifest.lock | 12 + Pods/Pods.xcodeproj/project.pbxproj | 604 ++++++++++ .../JTAppleCalendar/Info.plist | 26 + .../JTAppleCalendar/JTAppleCalendar-dummy.m | 5 + .../JTAppleCalendar-prefix.pch | 12 + .../JTAppleCalendar-umbrella.h | 16 + .../JTAppleCalendar/JTAppleCalendar.modulemap | 6 + .../JTAppleCalendar/JTAppleCalendar.xcconfig | 10 + .../Pods-EventTracker/Info.plist | 26 + ...ods-EventTracker-acknowledgements.markdown | 26 + .../Pods-EventTracker-acknowledgements.plist | 58 + .../Pods-EventTracker-dummy.m | 5 + .../Pods-EventTracker-frameworks.sh | 99 ++ .../Pods-EventTracker-resources.sh | 102 ++ .../Pods-EventTracker-umbrella.h | 16 + .../Pods-EventTracker.debug.xcconfig | 11 + .../Pods-EventTracker.modulemap | 6 + .../Pods-EventTracker.release.xcconfig | 11 + 46 files changed, 5676 insertions(+), 33 deletions(-) create mode 100644 EventTracker.xcworkspace/contents.xcworkspacedata create mode 100644 EventTracker/CalViewController.swift create mode 100644 EventTracker/CustomCell.swift create mode 100644 EventTracker/HeaderView.swift create mode 100644 Podfile create mode 100644 Podfile.lock create mode 100644 Pods/JTAppleCalendar/LICENSE create mode 100644 Pods/JTAppleCalendar/README.md create mode 100644 Pods/JTAppleCalendar/Sources/CalendarEnums.swift create mode 100644 Pods/JTAppleCalendar/Sources/CalendarStructs.swift create mode 100644 Pods/JTAppleCalendar/Sources/GlobalFunctionsAndExtensions.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCalendarDelegateProtocol.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCalendarLayout.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCalendarLayoutProtocol.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCalendarVariables.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCalendarView.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCell.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTAppleCollectionReusableView.swift create mode 100644 Pods/JTAppleCalendar/Sources/JTCalendarProtocols.swift create mode 100644 Pods/JTAppleCalendar/Sources/UICollectionViewDelegates.swift create mode 100644 Pods/JTAppleCalendar/Sources/UIScrollViewDelegates.swift create mode 100644 Pods/JTAppleCalendar/Sources/UserInteractionFunctions.swift create mode 100644 Pods/Manifest.lock create mode 100644 Pods/Pods.xcodeproj/project.pbxproj create mode 100644 Pods/Target Support Files/JTAppleCalendar/Info.plist create mode 100644 Pods/Target Support Files/JTAppleCalendar/JTAppleCalendar-dummy.m create mode 100644 Pods/Target Support Files/JTAppleCalendar/JTAppleCalendar-prefix.pch create mode 100644 Pods/Target Support Files/JTAppleCalendar/JTAppleCalendar-umbrella.h create mode 100644 Pods/Target Support Files/JTAppleCalendar/JTAppleCalendar.modulemap create mode 100644 Pods/Target Support Files/JTAppleCalendar/JTAppleCalendar.xcconfig create mode 100644 Pods/Target Support Files/Pods-EventTracker/Info.plist create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-acknowledgements.markdown create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-acknowledgements.plist create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-dummy.m create mode 100755 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-frameworks.sh create mode 100755 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-resources.sh create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-umbrella.h create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker.debug.xcconfig create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker.modulemap create mode 100644 Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker.release.xcconfig diff --git a/EventTracker.xcodeproj/project.pbxproj b/EventTracker.xcodeproj/project.pbxproj index 05dab9b..0e68ba4 100644 --- a/EventTracker.xcodeproj/project.pbxproj +++ b/EventTracker.xcodeproj/project.pbxproj @@ -19,6 +19,10 @@ C3E38CCF1AF7E5D40020EB86 /* EventTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E38CCE1AF7E5D40020EB86 /* EventTrackerTests.swift */; }; C3F3A4931CC69EEA00B35A27 /* AddCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F3A4921CC69EEA00B35A27 /* AddCalendarViewController.swift */; }; C3F3A4951CC6A62A00B35A27 /* CalendarAddedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3F3A4941CC6A62A00B35A27 /* CalendarAddedDelegate.swift */; }; + C8227DB11F5BACD300D191FC /* CalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8227DB01F5BACD300D191FC /* CalViewController.swift */; }; + C8EE12B71F5BBB9100DEA598 /* CustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8EE12B61F5BBB9100DEA598 /* CustomCell.swift */; }; + C8EE12BB1F5CC62E00DEA598 /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8EE12BA1F5CC62E00DEA598 /* HeaderView.swift */; }; + CA3E79984798E4F429C1B444 /* Pods_EventTracker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B68FDD6AF95090497EE61FA /* Pods_EventTracker.framework */; }; F2FE1C091AF8746D002A3F21 /* UIViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2FE1C081AF8746D002A3F21 /* UIViewExtensions.swift */; }; /* End PBXBuildFile section */ @@ -33,6 +37,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 02126327D8820F5F7CE8BC61 /* Pods-EventTracker.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EventTracker.debug.xcconfig"; path = "Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker.debug.xcconfig"; sourceTree = ""; }; + 3328A2715EE003AA23F06430 /* Pods-EventTracker.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EventTracker.release.xcconfig"; path = "Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker.release.xcconfig"; sourceTree = ""; }; + 6B68FDD6AF95090497EE61FA /* Pods_EventTracker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_EventTracker.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C332DA4E1CECE0F200E2D738 /* AddEventViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddEventViewController.swift; sourceTree = ""; }; C332DA501CF4C53E00E2D738 /* EventAddedDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventAddedDelegate.swift; sourceTree = ""; }; C3B8EA391CCFDB7900EE0C9D /* SegueIdentifiers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegueIdentifiers.swift; sourceTree = ""; }; @@ -49,6 +56,9 @@ C3E38CCE1AF7E5D40020EB86 /* EventTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTrackerTests.swift; sourceTree = ""; }; C3F3A4921CC69EEA00B35A27 /* AddCalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddCalendarViewController.swift; sourceTree = ""; }; C3F3A4941CC6A62A00B35A27 /* CalendarAddedDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarAddedDelegate.swift; sourceTree = ""; }; + C8227DB01F5BACD300D191FC /* CalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalViewController.swift; sourceTree = ""; }; + C8EE12B61F5BBB9100DEA598 /* CustomCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCell.swift; sourceTree = ""; }; + C8EE12BA1F5CC62E00DEA598 /* HeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; F2FE1C081AF8746D002A3F21 /* UIViewExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtensions.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -57,6 +67,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + CA3E79984798E4F429C1B444 /* Pods_EventTracker.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -70,12 +81,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2CFD8269E035D16F55598361 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6B68FDD6AF95090497EE61FA /* Pods_EventTracker.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; C3E38CAA1AF7E5D40020EB86 = { isa = PBXGroup; children = ( C3E38CB51AF7E5D40020EB86 /* EventTracker */, C3E38CCB1AF7E5D40020EB86 /* EventTrackerTests */, C3E38CB41AF7E5D40020EB86 /* Products */, + CE9060D6FBE35400E5B1E495 /* Pods */, + 2CFD8269E035D16F55598361 /* Frameworks */, ); sourceTree = ""; }; @@ -104,6 +125,9 @@ C3E38CBF1AF7E5D40020EB86 /* Images.xcassets */, C3E38CC11AF7E5D40020EB86 /* LaunchScreen.xib */, C3E38CB61AF7E5D40020EB86 /* Supporting Files */, + C8227DB01F5BACD300D191FC /* CalViewController.swift */, + C8EE12B61F5BBB9100DEA598 /* CustomCell.swift */, + C8EE12BA1F5CC62E00DEA598 /* HeaderView.swift */, ); path = EventTracker; sourceTree = ""; @@ -133,6 +157,15 @@ name = "Supporting Files"; sourceTree = ""; }; + CE9060D6FBE35400E5B1E495 /* Pods */ = { + isa = PBXGroup; + children = ( + 02126327D8820F5F7CE8BC61 /* Pods-EventTracker.debug.xcconfig */, + 3328A2715EE003AA23F06430 /* Pods-EventTracker.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -140,9 +173,12 @@ isa = PBXNativeTarget; buildConfigurationList = C3E38CD21AF7E5D40020EB86 /* Build configuration list for PBXNativeTarget "EventTracker" */; buildPhases = ( + 3AD9F1771921FB733D0C0D48 /* [CP] Check Pods Manifest.lock */, C3E38CAF1AF7E5D40020EB86 /* Sources */, C3E38CB01AF7E5D40020EB86 /* Frameworks */, C3E38CB11AF7E5D40020EB86 /* Resources */, + F7F18C6A4C2C867B155A7119 /* [CP] Embed Pods Frameworks */, + 53A4FA23026756075A59D001 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -179,7 +215,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = "Andrew Bancroft"; TargetAttributes = { C3E38CB21AF7E5D40020EB86 = { @@ -232,16 +268,67 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 3AD9F1771921FB733D0C0D48 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 53A4FA23026756075A59D001 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + F7F18C6A4C2C867B155A7119 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EventTracker/Pods-EventTracker-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ C3E38CAF1AF7E5D40020EB86 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( C3F3A4931CC69EEA00B35A27 /* AddCalendarViewController.swift in Sources */, + C8227DB11F5BACD300D191FC /* CalViewController.swift in Sources */, + C8EE12B71F5BBB9100DEA598 /* CustomCell.swift in Sources */, C332DA4F1CECE0F200E2D738 /* AddEventViewController.swift in Sources */, C3E38CBB1AF7E5D40020EB86 /* ViewController.swift in Sources */, C3F3A4951CC6A62A00B35A27 /* CalendarAddedDelegate.swift in Sources */, F2FE1C091AF8746D002A3F21 /* UIViewExtensions.swift in Sources */, + C8EE12BB1F5CC62E00DEA598 /* HeaderView.swift in Sources */, C332DA511CF4C53E00E2D738 /* EventAddedDelegate.swift in Sources */, C3B8EA3C1CCFDFA700EE0C9D /* EventsViewController.swift in Sources */, C3E38CB91AF7E5D40020EB86 /* AppDelegate.swift in Sources */, @@ -300,8 +387,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -346,8 +435,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -366,6 +457,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -373,6 +465,7 @@ }; C3E38CD31AF7E5D40020EB86 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 02126327D8820F5F7CE8BC61 /* Pods-EventTracker.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = EventTracker/Info.plist; @@ -385,6 +478,7 @@ }; C3E38CD41AF7E5D40020EB86 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 3328A2715EE003AA23F06430 /* Pods-EventTracker.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = EventTracker/Info.plist; diff --git a/EventTracker.xcworkspace/contents.xcworkspacedata b/EventTracker.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919d0d2 --- /dev/null +++ b/EventTracker.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/EventTracker/AddEventViewController.swift b/EventTracker/AddEventViewController.swift index 778f2ba..4788ddf 100644 --- a/EventTracker/AddEventViewController.swift +++ b/EventTracker/AddEventViewController.swift @@ -12,6 +12,7 @@ import EventKit class AddEventViewController: UIViewController { var calendar: EKCalendar! + var eventStore : EKEventStore! @IBOutlet weak var eventNameTextField: UITextField! @IBOutlet weak var eventStartDatePicker: UIDatePicker! @@ -21,7 +22,7 @@ class AddEventViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. + eventStore = EKEventStore() self.eventStartDatePicker.setDate(initialDatePickerValue(), animated: false) self.eventEndDatePicker.setDate(initialDatePickerValue(), animated: false) } @@ -44,21 +45,27 @@ class AddEventViewController: UIViewController { @IBAction func addEventButtonTapped(_ sender: UIBarButtonItem) { // Create an Event Store instance - let eventStore = EKEventStore(); - + //let eventStore = EKEventStore(); + print("adding event to \(calendar.title)") // Use Event Store to create a new calendar instance - if let calendarForEvent = eventStore.calendar(withIdentifier: self.calendar.calendarIdentifier) - { - let newEvent = EKEvent(eventStore: eventStore) - - newEvent.calendar = calendarForEvent + //if let calendarForEvent = calendar { + //if let calendarForEvent = eventStore.calendar(withIdentifier: self.calendar.calendarIdentifier) + print("there is a calendar") + let newEvent = EKEvent(eventStore: self.eventStore) + newEvent.calendar = calendar newEvent.title = self.eventNameTextField.text ?? "Some Event Name" newEvent.startDate = self.eventStartDatePicker.date newEvent.endDate = self.eventEndDatePicker.date - + print(newEvent.calendar.title) + print(newEvent.title) + print(newEvent.startDate) + print(newEvent.endDate) + // Save the event using the Event Store instance do { - try eventStore.save(newEvent, span: .thisEvent, commit: true) + print("trying to save") + try self.eventStore.save(newEvent, span: .thisEvent) + delegate?.eventDidAdd() self.dismiss(animated: true, completion: nil) @@ -69,6 +76,6 @@ class AddEventViewController: UIViewController { self.present(alert, animated: true, completion: nil) } - } + //} } } diff --git a/EventTracker/Base.lproj/Main.storyboard b/EventTracker/Base.lproj/Main.storyboard index a02ddea..620a309 100644 --- a/EventTracker/Base.lproj/Main.storyboard +++ b/EventTracker/Base.lproj/Main.storyboard @@ -1,7 +1,10 @@ - - + + + + + - + @@ -15,12 +18,14 @@ - + +