Search code examples
iosswiftremindersekeventstore

Fetching reminders using Swift Syntax


I am trying to asynchronously fetch reminders (EKEntityTypeReminder) from EventKit. How do I write this in Swift?

[_store fetchRemindersMatchingPredicate:predicate completion:^(NSArray *reminders) {
    for (EKReminder *reminder in reminders) {
        NSLog(@"Reminder %@",reminder);
    }
}];

… still struggling with adapting to the new Blocks/Closures syntax


Solution

  • store.fetchRemindersMatchingPredicate(predicate) { reminders in
        for reminder in reminders {
    
        }
    }
    

    I prefer using trailing closure syntax

    Otherwise it could be...

    store.fetchRemindersMatchingPredicate(predicate, completion: {(reminders: [AnyObject]!) -> Void in
        for reminder in reminders {
    
        }
    })