Post

Replies

Boosts

Views

Activity

How to enable the Delete key shortcut in the Edit menu of a SwiftUI App on macOS?
If I add the .onDeleteCommand to a List, the Edit -> Delete menu item is enabled when a row is selected. However, the delete key doesn't work. I see that the menu item doesn't have the shortcut listed. When trying to replace it using a CommandGroup, the shortcut becomes command + delete. How do I get the Edit -> Delete MenuItem to use the delete key shortcut? Or how do I enable using the delete key to delete rows in a List on the macOS? @main struct MyApp: App { &#9;&#9; &#9;&#9;var body: some Scene { &#9;&#9;&#9;&#9;WindowGroup { &#9;&#9;&#9;&#9;&#9;&#9;ContentView() &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;// Turns it into command+delete //&#9;&#9;&#9;&#9;.commands { //&#9;&#9;&#9;&#9;&#9;&#9;CommandGroup(replacing: CommandGroupPlacement.pasteboard) { //&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Button("Delete", action: { //&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("Custom Delete") //&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}) //&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.keyboardShortcut(.delete) //&#9;&#9;&#9;&#9;&#9;&#9;} //&#9;&#9;&#9;&#9;} &#9;&#9;} } struct ContentView: View { &#9;&#9;@State var data = Data() &#9;&#9;@State var selection = Set<Int>() &#9;&#9; &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;List.init(data.models, id: \.id, selection: $selection) { &#9;&#9;&#9;&#9;&#9;&#9;Text("Name: \($0.name)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;.keyboardShortcut(.delete)&#9;// This does not work &#9;&#9;&#9;&#9;.onDeleteCommand(perform: { // This works when clicking in the menu &#9;&#9;&#9;&#9;&#9;&#9;print("Delete row") &#9;&#9;&#9;&#9;}) &#9;&#9;} } struct Model: Identifiable { &#9;&#9;let id: Int &#9;&#9;let name: String } struct Data { &#9;&#9;var models = [Model(id: 1, name: "First")] }
0
1
1.2k
Nov ’20
CloudKit Permissions
If I used a private db, I have different uses and permissions for different tables. I'm trying to figure out how I can setup the table permissions in a similar way in CloudKit. For example, a countries table (admin:read/write, user:read) Only managed by an admin The data can be read by any user but not updated Data will be populated before any users have the app Is there a related store in CloudKit for this use case? Next, a users table (admin:read/write, user:read/limited write) When a user signs up, a new record is added. A user should have read and write access to only their record. Admins should have read and write access to all records. The read/write access is different from the countries example. How would this be handled in CloudKit?
1
0
2.9k
Oct ’20
How do I get Xcode Server to send emails
I have postfix setup. I confirmed by sending test emails. If I watch the logs, I can see the emails being sent: log stream --predicate&#9;'(process == "smtpd") || (process == "smtp")' --info 2020-10-07 09:20:05.110042-0700 0x797f8 Info 0x0 44288 0 smtp: 697E213FE996: to=<MY@EMAIL.com>, relay=email-smtp.us-east-1.amazonaws.com[3.209.161.67]:587, delay=15, delays=14/0/0.83/0.84, dsn=2.0.0, status=sent (250 Ok 0100017503dcd187-5b1e6a31-4a69-478e-9d61-0bed900f21a1-000000) In the Xcode build service logs, I can see that it starts the email step, but I don't see the log being create in the mail logs /Library/Developer/XcodeServer/IntegrationAssets/db3c6b6a0ee11805255ff018f876ebe7-ServerTest\ Bot/5/buildService.log Oct 7 09:22:53 [7704] <Info>: Executing trigger 'Periodic Email Report' Oct 7 09:22:53 [7704] <Info>: Completed integration step XCSTriggersIntegrationStep without error As for the Xcode email settings, I have tried both empty fields as suggested on stackoverflow and filling them in correctly. Neither seem to work.
0
0
515
Oct ’20
How to sign a JWT with Apple's CryptoKit
In the Sign in With Apple docs - https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens regarding signing a JWT After creating the JWT, sign it using the Elliptic Curve Digital Signature Algorithm (ECDSA) with the P-256 curve and the SHA-256 hash algorithm. A decoded client_secret JWT token has the following format... There aren't any steps to sign it. I found some references to P256 - https://developer.apple.com/documentation/cryptokit/p256?changes=latest_minor in the docs. Does anyone know how to use Apple's CryptoKit to sign a JWT?
0
0
1k
Aug ’20