Apple Event object property hasAlarms returning incorrect boolean value

43 views Asked by At

I am attempting to wrap a number of EkEventkit objective-c commands using Livecode Builder using its Foreign Function Interface (FFI). I have created a library for use by Livecode Script but when run the Event property "hasAlarms" returns true on events that have no alarm set. The odd thing is that repeat events that were entered into my calendar many years ago and therefore several OS versions ago appear to report correct values.

The FFI definition I am using is

private foreign handler Objc_EventHasAlarms(in pEventObj as objcID) \
                        returns optional CBool \
                        binds to "objc:EventKit>EKEvent.hasAlarms"

The code above does not throw any errors so I wonder if I have stumbled across a bug in the Calendar (v11) application running on Big Sur. Any thoughts?

1

There are 1 answers

1
Monte Goulding On

The issue is likely caused by your return value returns optional CBool which should be returns CBool

So:

private foreign handler Objc_EventHasAlarms(in pEventObj as ObjcId) \
                        returns CBool \
                        binds to "objc:EventKit>EKCalendarItem.-hasAlarms"

A further suggestion would be to check the result of:

private foreign handler Objc_EventAlarms(in pEventObj as ObjcId) \
                        returns optional ObjcId \
                        binds to "objc:EventKit>EKCalendarItem.-alarms"

via:

if Objc_EventAlarms(tCalendarItem) is nothing then
   -- no alarms
end if