Thursday, August 16, 2018

#1 2018-06-09 12:14:27 pm

Registered: 2010-04-04
Posts: 77

EventKit modificationDate versus creationDate

When scripting EventKit, although I am able to abstract the creation date of an EK event, I am unable to do the same with  EK event's modification date.
I have included only the part of my applescript that raised the error. I can include the remainder of the script,if it would make it easier to comprehend the reason for Applescript's error.   


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
use framework "EventKit"
script to create an instance of EKEventStore

set newEvent to current application's EKEvent's eventWithEventStore:theEKEventStore

# getting the event's creation date yields an NS Date
set creationDate to newEvent's creationDate() --> (NSDate) "2018-06-09 17:42:33 +0000"

# getting the event's modification date throws an error
set modficationDate to newEvent's modificationDate() --> -[EKEvent modificationDate]: unrecognized selector sent to instance 0x60c0001ba4e0

1.  Why would EventKit respond to creationDate but not to modificationDate?
2.  How do I script the instance to recognize the selector, in order to abstract its modification date?



#2 2018-06-09 01:29:32 pm

Nigel Garvey
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4620

Re: EventKit modificationDate versus creationDate


According to the Xcode documentation, EKEvents inherit creationDate and lastModifiedDate properties from class EKCalendarItem. So you want the event's lastModifiedDate().




Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)