我正在尝试从EventKit异步获取提醒(EKEntityTypeReminder)。我如何在Swift中写这个?
[_store fetchRemindersMatchingPredicate:predicate completion:^(NSArray *reminders) {
for (EKReminder *reminder in reminders) {
NSLog(@"Reminder %@",reminder);
}
}];
......仍在努力适应新的Block / Closures语法
答案 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 {
}
})