Last active
July 12, 2016 16:29
-
-
Save deepakg/06979f6d6e3f06932761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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