If I wanted to look through my OS X Calendar (formerly "iCal") to find events whose summary was "Lunch", I could do something like this:
var eventsContainer = Application('Calendar').calendars[0].events
for (var i = 0; i < eventsContainer.length; i++) {
var thisEvent = eventsContainer[i];
if (thisEvent.summary() == 'Lunch') { doSomething() }
}
even taking into account the fact that this only searches the first calendar, it's very, very, very slow, since each iCal event needs to be translated to a Javascript object to run. Here's a formulation that is substantially faster:
var foundEvents = Application('Calendar').calendars.events.whose({summary: 'Lunch'});
This works great for an exact match summary == 'Lunch'
. But what about comparisons such as endDate: > new Date()
or summary: /lunch/i
? Is it possible to pass native (ObjC) code into a whose() selector? Is there any documentation anywhere for whose()
that would help?