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
NSLog("Authorized")
Case EKAuthorizationStatus.Denied
NSLog("Denied")
Case EKAuthorizationStatus.NotDetermined
store.requestAccessToEntityType(EKEntityType.EKEntityTypeReminder, Sub(ByVal granted As Boolean, ByVal err As NSError)
If granted Then
NSLog("Access granted")
Else
NSLog("Access denied")
End If
End Sub)
Case Else
NSLog("Unknown")
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")
Else
NSLog("Access denied")
End If
End Sub
store.requestAccessToEntityType(EKEntityType.EKEntityTypeReminder, completion: reqAccess)
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?
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.