Mercury Syntax for requesting Access from EventStore on iOS

Fire, Xcode: 12.5.1, using Mercury.

I’m trying to request access to reminder data stored in iOS. Somehow I can’t quite get the syntax correct in Mercury. Here’s my code:

    Dim store  As new EKEventStore()
    Select Case store.authorizationStatusForEntityType(EKEntityType.EKEntityTypeReminder)
      Case EKAuthorizationStatus.Authorized
      Case EKAuthorizationStatus.Denied
      Case EKAuthorizationStatus.NotDetermined
        store.requestAccessToEntityType(EKEntityType.EKEntityTypeReminder, Sub(ByVal granted As Boolean, ByVal err As NSError)
        If granted Then
          NSLog("Access granted")
            NSLog("Access denied")
        End If
        End Sub)
      Case Else

The compiler complains like so:

And here’s what the build log says:

Any suggestions? I’ve tried a bunch of different things, but so far I pretty much end up in this same place. Thanks,


Nevermind, I seem to have figured out some syntax that works, although of course if there is something else you recommend please let me know.

  Public Delegate Sub RequestAccessDelegate(ByVal granted As Boolean, ByVal Err As NSError)

    Dim store  As new EKEventStore()

    Dim reqAccess As RequestAccessDelegate = Sub(ByVal a As Boolean, ByVal b As NSError)
    If a Then
        NSLog("Access granted")
        NSLog("Access denied")
      End If  
    End Sub
    store.requestAccessToEntityType(EKEntityType.EKEntityTypeReminder, completion: reqAccess)


There is one minor thing going on that I don’t quite understand.

When this code executes in Fire, it stops on this line like so:

I don’t see an error reported anywhere, and if I use Debug => Continue, it works as expected.

Should I be concerned about this? It is a bit annoying, so maybe there is some setting I can use to turn it off if it isn’t reporting anything of concern?


Oh my goodness, it’s a breakpoint LOL!

Obviously I need a “break” myself!

Nevermind again! At least I figured it out myself.


1 Like

Yep, thats the correct syntax; the second parameter is named, see Multi-Part Method Names.

It looks like you have a breakpoint set at that line, as indicated by the blue marker?

Yep, I obviously need more caffeine or something! I don’t know how I could have missed that breakpoint.

Thanks for the documentation pointer - I’m pretty sure I read that page quite a while ago, before the Mercury syntax was added. Reviewing it again will be good for me. :slight_smile: