使用Swift语法获取提醒

时间:2014-08-11 18:29:00

标签: ios swift reminders ekeventstore

我正在尝试从EventKit异步获取提醒(EKEntityTypeReminder)。我如何在Swift中写这个?

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

......仍在努力适应新的Block / Closures语法

1 个答案:

答案 0 :(得分:6)

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

    }
}

我更喜欢使用trailing closure syntax

否则可能是......

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

    }
})