Post

Replies

Boosts

Views

Activity

Enable Undo CoreData SwiftUI
Does anyone know how to have the Undo command in the menu bar enable when CoreData UndoManager has items to undo? Here’s what I’ve done: At app init I’m setting the Core Data PersistanceController UndoManager() persistenceController.container.viewContext.undoManager = UndoManager() I can confirm the CoreData undoManager is set because I can programmatically call undo and it works (for instance after deletion) HOWEVER the Undo command in the menuBar remains disabled. As a side-note, the Undo command in the menuBar works correctly when I’m writing text in a TextField (it does automatically enable to undo text changes). Huge thanks in advance, been trying things for a while and can’t find anything online
1
0
1.2k
Aug ’22
Restoring macOS window size after close using SwiftUI WindowsGroup
By default, on a macOS app using SwiftUI the window size is not restored after the window is closed. Is there a way to keep whatever size & position the user gave before closing the app. Essentially I'd like close & open to behave in the same way to when the user quits & opens the app? Is there something that should be added here? import SwiftUI @main struct testApp: App { var body: some Scene { WindowGroup { ContentView() } } } Thanks in advance!
1
0
978
Apr ’22
Enable Undo CoreData SwiftUI
Does anyone know how to have the Undo command in the menu bar enable when CoreData UndoManager has items to undo? Here’s what I’ve done: At app init I’m setting the Core Data PersistanceController UndoManager() persistenceController.container.viewContext.undoManager = UndoManager() I can confirm the CoreData undoManager is set because I can programmatically call undo and it works (for instance after deletion) HOWEVER the Undo command in the menuBar remains disabled. As a side-note, the Undo command in the menuBar works correctly when I’m writing text in a TextField (it does automatically enable to undo text changes). Huge thanks in advance, been trying things for a while and can’t find anything online
Replies
1
Boosts
0
Views
1.2k
Activity
Aug ’22
Restoring macOS window size after close using SwiftUI WindowsGroup
By default, on a macOS app using SwiftUI the window size is not restored after the window is closed. Is there a way to keep whatever size & position the user gave before closing the app. Essentially I'd like close & open to behave in the same way to when the user quits & opens the app? Is there something that should be added here? import SwiftUI @main struct testApp: App { var body: some Scene { WindowGroup { ContentView() } } } Thanks in advance!
Replies
1
Boosts
0
Views
978
Activity
Apr ’22
Binding -> Return from initializer without initializing all stored properties
When trying to add search to my app I get the warning "Return from initializer without initializing all stored properties" due to my Binding. But seems to me I'm doing exactly what the video is doing:     @Binding var searchableText: String Thoughts?
Replies
2
Boosts
0
Views
1.4k
Activity
Jul ’21