Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
1 answer
86 views

Some List Items not editable using .move in SwiftUI List

I modified the default Items example from xcode to include two models, a view with a query and a detail view. On this detail view I cannot properly move all items, only the top two, please see the ...
ThomasDeLange's user avatar
1 vote
0 answers
91 views

Disable a `contextMenu` button conditionally depending on the list item

I'm using SwiftData with SwiftUI. I want to disable a contextMenu button on a list item conditionally depending on the list item itself. E.g. I have a parent-child model as one-to-many relationship. ...
Weishi Z's user avatar
  • 1,718
0 votes
1 answer
568 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 ...
Amar Sagoo's user avatar
0 votes
3 answers
487 views

How to reliably delete out of a SwiftData container with .onDelete method?

I am fairly new to the iOS programming world and definitely new to SwiftData, so hopefully this isn't too much of a stupid question... My SwiftData Schema consists of a one to many to many model. A ...
Dillonmk's user avatar
-1 votes
1 answer
394 views

How to delete persistent model objects?

I have a very simple project, it currently consists of a model of clients, and a list of those clients. Quite simple. I am getting this error: Instance method 'delete' requires that '[Client]' conform ...
rhythmsticks's user avatar
1 vote
0 answers
965 views

How can I group the SwiftData @Query result by date Sections to display in a SwiftUI List

I want to display a SwiftData Model in my List and have it grouped by month. So each section will list the items with their date falling in that month. An example would be like below: @Model final ...
alionthego's user avatar
  • 9,343
0 votes
0 answers
42 views

I have a picker that does not return the selected item [duplicate]

@Query(sort: \roleModel.role) var roles: [roleModel] @State var selectedRole = "" var body: some View { `VStsck` `Text("You selected: \(selectedRole)") // Display the ...
Bob's user avatar
  • 1