Post

Replies

Boosts

Views

Activity

Reply to .searchable modifier with a keyboard shortcut
I ended up getting the following to work on macOS using the .searchable() modifier (only tested on macOS 12.3): import SwiftUI @main struct MyApp: App {     @State var searchText = ""     var items = ["Item 1", "Item 2", "Item 3"]     var searchResults: [String] {         if searchText.isEmpty {             return items         } else {             return items.filter { $0.contains(searchText) }         }     }     var body: some Scene {         WindowGroup {             List(self.searchResults, id: \.self) { item in                 Text(item)             }.searchable(text: self.$searchText)         }.commands {             CommandMenu("Find") {                 Button("Find") {                     if let toolbar = NSApp.keyWindow?.toolbar,                         let search = toolbar.items.first(where: { $0.itemIdentifier.rawValue == "com.apple.SwiftUI.search" }) as? NSSearchToolbarItem {                         search.beginSearchInteraction()                     }                 }.keyboardShortcut("f", modifiers: .command)             }         }     } }
Apr ’22
Reply to CloudKit Subscriptions - weird things going on
It looks like it could be related to the patch Apple rolled out last week in relation to using NSPredicate: https://www.trellix.com/en-us/about/newsroom/stories/research/trellix-advanced-research-center-discovers-a-new-privilege-escalation-bug-class-on-macos-and-ios.html The subscriptions I use that do NSPredicate(value: true) do not have an issue being saved to the database.
Feb ’23