-
Notifications
You must be signed in to change notification settings - Fork 41
How to access enum values and provide a completionHandler? (Request iOS local notification permission) #33
Copy link
Copy link
Open
Description
I have been exploring if I can use zig-objc to replace my clunky swift side build. I first checked to see if there was sample code that might demonstrate the intent for how we would access enum values (to create an NSUInteger) and how to provide a completionHandler
// UNUserNotificationCenter *un = [UNUserNotificationCenter currentNotificationCenter];
const un = objc.getClass("UNUserNotificationCenter").?;
const cnc = un.msgSend(objc.Object, "currentNotificationCenter", .{});
// https://developer.apple.com/documentation/usernotifications/unauthorizationoptions
// UNAuthorizationOptions options = UNAuthorizationOptionAlert +
// UNAuthorizationOptionSound +
// UNAuthorizationOptionBadge;
const options = objc.enum??.UNAuthorizationOptions??? //enum UNAuthorizationOptions : NSUInteger;
//[un requestAuthorizationWithOptions:(UNAuthorizationOptions) options
// completionHandler:(void (^)(BOOL granted, NSError *error)) completionHandler];
cnc.msgSend(objc.Object, "requestAuthorizationWithOptions", .{
options,
completionHandler, // Can this be just a function?
});
}Any input would be greatly appreciated.
PS: By way of feedback, I wonder if we could get an /examples folder for zig-objc to demonstrate some more advanced basic patterns like this. Thanks for your work on this cool zig project.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels