Commit 5d98cc77 authored by Adam Procter's avatar Adam Procter

Updated to allow textfield reminder input and added code comments

parent 7c42c518
......@@ -11,18 +11,20 @@ import EventKit
class ViewController: UIViewController {
// setting the EventKit Vars ready for use
var eventStore = EKEventStore()
var calendars:Array<EKCalendar> = []
// the input field
@IBOutlet weak var reminderText: UITextField!
// the button
@IBAction func setReminder(_ sender: Any) {
// storing the data into the store
let reminder = EKReminder(eventStore: self.eventStore)
reminder.title = "Go to the store and buy milk"
reminder.title = reminderText.text!
reminder.calendar = eventStore.defaultCalendarForNewReminders()
do {
......@@ -39,6 +41,8 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// here we grant access to the store (pop over thing appears)
// dont forget to add the plist entry for access as well
eventStore.requestAccess(to: EKEntityType.reminder, completion:
{(granted, error) in
......@@ -46,13 +50,15 @@ class ViewController: UIViewController {
print("Access to store not granted")
}
})
// now we need to get the calendars and pop them into the array we set to begin with
calendars = eventStore.calendars(for: EKEntityType.reminder)
for calendar in calendars as [EKCalendar] {
print("Calendar = \(calendar.title)")
}
//
// for calendar in calendars as [EKCalendar] {
// /// loop them to print
// print("Calendar = \(calendar.title)")
// }
//
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment