I'm trying to use Objective-C Bridge in a Javascript for Automation script to access the Event Store. Here's my code:
ObjC.import('EventKit');
var store = $.EKEventStore.alloc.initWithAccessToEntityTypes($.EKEntityMaskReminder);
var predicate = store.predicateForRemindersInCalendars($.Nil);
store.fetchRemindersMatchingPredicateCompletion(predicate, function(reminders){
console.log(reminders)
});
However the script completes, presumably before the function is called- nothing appears in the log.
Is there a way to make this work, such as to make it run synchronously instead, or to make the script wait until the completion handler finishes?