Skip to content

Instantly share code, notes, and snippets.

@deepakg
Last active July 12, 2016 16:29
Show Gist options
  • Save deepakg/06979f6d6e3f06932761 to your computer and use it in GitHub Desktop.
Save deepakg/06979f6d6e3f06932761 to your computer and use it in GitHub Desktop.
//
// main.swift
// eventkitter
//
// Created by Deepak Gulati on 15/06/2014.
// Prints all the unfinished reminders from the default reminder list
import Foundation
import EventKit
let ev:EKEventStore = EKEventStore()
var done = false
var currentLoop:NSRunLoop = NSRunLoop.currentRunLoop()
func printReminders (ev:EKEventStore) {
let defaultList = ev.defaultCalendarForNewReminders()
let searchFor = [defaultList]
let predicate = ev.predicateForIncompleteRemindersWithDueDateStarting(nil, ending: nil, calendars: searchFor)
ev.fetchRemindersMatchingPredicate(predicate, completion: {
(reminders: AnyObject[]!) in
for item:AnyObject in reminders {
let reminder = item as? EKReminder
let title = reminder?.title
println(title)
}
done = true
})
}
ev.requestAccessToEntityType(EKEntityTypeReminder, completion: {
(status: Bool, error: NSError!) in
println(status)
printReminders(ev)
})
do {
currentLoop.runUntilDate(NSDate(timeIntervalSinceNow:1))
} while (!done)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment