Post

Replies

Boosts

Views

Activity

Reply to (Xcode 14.0 beta 5) ThreadSanitizer: CHECK failed: tsan_platform_posix.cpp:83 "((beg)) <= ((end))"
On my Intel MBP is get a different error when the thread sanitizer is on. "malloc: nano zone abandoned due to inability to preallocate reserved vm space." StackOverflow suggests this is relatively harmless, but paired with the error I get on my Mac Mini (Apple Silicon) There's something afoul. [https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space]
Aug ’22
Reply to Custom File "New Document" to show template-picker in a document-based app
Answering my own question. I want to use Commands. See newItem. Here's an example: struct DocDemoApp: App {     @Environment(\.openWindow) var openWindow     @Environment(\.openDocument) private var openDocument     var body: some Scene {         DocumentGroup(newDocument: { DocDemoDocument() }) { config in             ContentView(document: config.document)         }         Window("Choose Template", id: "wizard") {             NewDocWizard()         }         .commands {             CommandGroup(replacing: .newItem) {                 Section {                     // Menu File >                     Button("New") { openWindow(id: "wizard") }.keyboardShortcut(KeyboardShortcut("N"))                     Button("Open") { open() }.keyboardShortcut(KeyboardShortcut("o"))                     Button("Open Recent...") { print("NYI") }                 }             }             CommandGroup(replacing: .singleWindowList) {                 // Menu Window > Choose Template, ... (list of single windows)                 // Hide and force user to use File > New for this window             }         }     }     private func open() {         let panel = NSOpenPanel()         panel.allowedContentTypes = [.exampleText]         panel.allowsMultipleSelection = true         panel.canChooseDirectories = false         panel.runModal()         if let url = panel.url {             Task {                 try! await openDocument(at: url)             }         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23
Reply to how to change appInfo in SwiftUI?
@Environment(\.openWindow) var openWindow Window("About", id: "about") {     MyAboutView() } .commands {     CommandGroup(replacing: .appInfo) {         Button(action: {             openWindow(id: "about")         }, label: {             Text("About MyAPP")         })     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’23