Lets challenge stackexchange[1] by crossposting my question here:
I am trying to iterate through the events in a calendar to copy them to
another:
tell application "iCal"
set localEvents to events of calendar "localCalendar"
set remoteEvents to events of calendar "remoteCalendar"
repeat with theLocalEvent in localEvents
if theLocalEvent is not in remoteEvents
copy theLocalEvent to end of events of calendar
"remoteCalendar"
end if
end repeat
end tell
This throws the following error:
error "«class wrev» id \"137CC1CB-43A8-445D-AD15-4ED6DFBCFA64\" of
«class wres» id \"08F222B5-C63B-4631-BE34-43D878F184D1\" of application
\"iCal\" kann nicht in Typ vector umgewandelt werden." number -1700
from «class wrev» id "137CC1CB-43A8-445D-AD15-4ED6DFBCFA64" of «class
wres» id "08F222B5-C63B-4631-BE34-43D878F184D1" to vector
So for now I first create a list of UIDs of the events to check before
I copy them if they are not in the list:
tell application "iCal"
set localEvents to events of calendar "localCalendar"
set remoteEvents to events of calendar "remoteCalendar"
set listOfRemoteEvents to {}
repeat with theRemoteEvent in remoteEvents
copy (uid of theRemoteEvent) to end of listOfRemoteEvents
end repeat
repeat with theLocalEvent in localEvents
if (uid of theLocalEvent) is not in listOfRemoteEvents then
copy theLocalEvent to end of events of calendar
"remoteCalendar"
end if
end repeat
end tell
This works, but I am sure that it's the worst algorithm in the world.
So I am wondering how I can iterate through the calendar more
gracefully.
[1]:
http://apple.stackexchange.com/questions/178222/how-to-iterate-through-ical-events-in-applescript