After finding code to save and find calendar events, I would like to write my own calendar app. But I still don't know how to write ObjectC code, sorry. So could you please tell me how to remove and change calendar events. That is my try to delete a calendar event (last line crashes pythonista). And there is only one event on 2018-12-30...
from objc_util import *
from ctypes import POINTER
import threading
import calendar, time
store = ObjCClass('EKEventStore').alloc().init()
access_granted = threading.Event()
def completion(_self, granted, _error):
access_granted.set()
completion_block = ObjCBlock(completion, argtypes=[c_void_p, c_bool, c_void_p])
store.requestAccessToEntityType_completion_(0, completion_block)
access_granted.wait()
startDate = ObjCClass('NSDate').dateWithTimeIntervalSince1970_(time.mktime(time.strptime('2018-12-30 00:00:00', '%Y-%m-%d %H:%M:%S')))
endDate = ObjCClass('NSDate').dateWithTimeIntervalSince1970_(time.mktime(time.strptime('2018-12-30 23:59:59', '%Y-%m-%d %H:%M:%S')))
predicate = store.predicateForEventsWithStartDate_endDate_calendars_(startDate, endDate, None)
event = store.eventsMatchingPredicate_(predicate)
print(event)
LP_c_void_p = POINTER(c_void_p)
err = LP_c_void_p()
#store.removeEvent_span_error_(event, 0, err)