All Questions
13
questions
2
votes
1
answer
36
views
How to share the same model container between WindowGroup and MenuBarExtra in SwiftUI?
I am working on a SwiftUI application where I need to share the same model container between a WindowGroup and a MenuBarExtra. The goal is to have both components update in sync without needing to ...
1
vote
0
answers
61
views
SwiftData rollback not updating the UI
I'm building a simple App using SwiftData. In my app a user can create, remove and edit posts. When editing, I want them to be able to hit "Save" to persist the changes or "Cancel" ...
0
votes
1
answer
67
views
Issue with observing SwiftData model and UndoManager
I have created a minimum example to demonstrate an issue with observing SwiftData model and UndoManager. This project includes a simple NavigationSplitView, an Item SwiftData model that is being ...
0
votes
0
answers
38
views
How to properly add data files into a SwiftData ModelDocument file package
I am working on a macOS/iOS sandboxed app with SwiftUI/SwiftData. The app saves its' data into a ModelDocument file. But I want to also save large binary data files into this file.
I create the ...
0
votes
1
answer
96
views
How to embed SwiftData model container in a custom file package document type
I have done a lot of research on this but am not able to come up with a workable solution to this problem. My knowledge and experience in Swift and SwiftUI/SwiftData/AppKit/UIKit is limited so I am ...
1
vote
1
answer
197
views
How to open a new window with dynamic data in a macOS App using SwiftData
I have have edited this question to try to make it more clear and added an Xcode project
To simulate the problem I am trying to solve which is just press a button and open a new window in macOS with a ...
0
votes
3
answers
100
views
Implementing Export/Import menu commands?
I have an import (and export) button(s) that works fine placed in a view.
var body: some View {
Button(action: {
isImporting = true
}, label: {
Label("Import", ...
1
vote
0
answers
76
views
Persistent SwiftData in 'Library/Containers' Directory After App Uninstallation on macOS
I've encountered an issue where SwiftData remains in the /Users/(username)/Library/Containers/~ directory even after my app has been deleted.(other apps too) This behavior is not what I expected.
Has ...
0
votes
1
answer
569
views
Right way to select newly added SwiftData object in NavigationSplitView?
I'm using a two-column NavigationSplitView to display SwiftData objects in a macOS app. After you add a new object, I want it to be selected in the sidebar. Although I've found a way to do this, it ...
0
votes
2
answers
342
views
SwiftUI View Not Updating After Create/Delete Operations on SwiftData Entities
I am working on a SwiftUI app that uses SwiftData for data persistence.
I've implemented a ContentViewModel that handles fetching, creating, updating, and deleting operations on SwiftData entities.
...
1
vote
0
answers
126
views
macOS SwiftUI: Share DocumentGroup's modelContext with separate WindowGroup
I have a SwiftUI document app for macOS with SwiftData storage. The DocumentGroup automatically injects a ModelContext to the environment of it's editor view. Now I want to have a separate window ...
0
votes
1
answer
461
views
How can I get data from SwiftData on Widget (macOS)
I want to fetch data from SwiftData on Widget but it returns empty data even though there are some data. How can I fetch data correctly?
Do I need to setup something in widget target to communicate ...
4
votes
1
answer
848
views
Sort SwiftData Query shown in SwiftUI Table on macOS
I have a mini macOS app, presenting some data persisted in SwiftData on a Table.
I want to sort the data by clicking on Table's column headers so I have a KeyPathComparator on the table.
But since the ...