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

All Questions

Tagged with
-1 votes
0 answers
39 views

How do relationships not cause infinite loops?

So I'm still learning SwiftData and the one thing I cannot get my head around is how relationships don't cause infinite loops. For example, using SwiftData, if you want to list all the films an actor ...
sam0701's user avatar
  • 11
0 votes
0 answers
61 views

Swiftdata crash when I try to delete some groups in the playlist

I guess something is wrong with my relations, I'm try to loop into the groups array and delete each one expecting that by cascade it delete also all the playlist items. I structure my model as follow: ...
Damiano Miazzi's user avatar
0 votes
0 answers
36 views

ContentUnavailableView causing entire page to be gray

I have add a List of workout that before I extracted to a subview would show the ContentUnavailableView as normal but since extracting it to a subview it now the ContentUnavailableView shows up but ...
Milan Labus's user avatar
2 votes
1 answer
82 views

Is it possible to join two SwiftData models into a single list?

I have three models SwiftData - a parent Event related to two others. I am trying to write a query that joins the two sub-models and filters to only show the results that match the selected event. ...
SwiftBleu's user avatar
0 votes
1 answer
39 views

How to do a Deep Copy in SwiftData

I have a workout model: @Model class Workout { var id: UUID var name: String? @Relationship(deleteRule: .cascade) //when deleting a workout you delete all exericses that happened ...
Milan Labus's user avatar
0 votes
0 answers
52 views

Referencing instance method requires that 'srfidTagData' conform to 'PersistentModel'

So I'm currently running into an issue where when I'm using this library I'm trying to create an array of the tag data inside the model, it worked perfectly fine before with strings but I'm getting ...
Caleb Brown's user avatar
0 votes
0 answers
33 views

How to pass optional Data to the child view to have different functionality based on if data is passed or not in SwiftUI

I have two ways to navigate to make CreateWorkout View, one is the user creating a new workout by tapping on a button in the toolbar: .toolbar { NavigationLink() { ...
Milan Labus's user avatar
0 votes
0 answers
101 views

Appintent and SwiftData

I'm new to Swift development and I am encountering an issue that I believe may be due to an error on my part. I have two questions regarding the following code: import AppIntents import SwiftUI import ...
Bruno Alves's user avatar
0 votes
0 answers
46 views

How do I access a variable that's using the @Query wrapper in other views?

I'm brand new to swift, and I've been learning how to use SwiftData at a basic level. I have an array of Item objects called "items" that is using the @Query wrapper so that it updates ...
snide_forever's user avatar
2 votes
1 answer
68 views

Is there any way reduce Query array which comes from SwiftData to single property?

I have two classes one shows cities, other shows concerts with many to many relationships. On concert view I have @Query var cities : [City] to select city name from picker. I'm trying to fetch ...
kocaman's user avatar
  • 41
-3 votes
1 answer
99 views

How to fetch model with pre-defined array of items and do update and delete in SwiftUI

I'm new to swiftui and i am trying to load the defined array in the model that i have adjusted example code form the xcode when you open a new project. in my case i want to load the array of dates ...
Armando's user avatar
0 votes
1 answer
245 views

Adding to SwiftData from a global array, not working as expected

This is the most basic of SwiftData setups, I started looking at this after encountering a problem in a much larger app. In the sample below the issue is that if you press the "Zoo" button ...
fuzzygoat's user avatar
  • 26.2k
0 votes
2 answers
883 views

SwiftData sorting order of Query array elements

I have a simple test app with a behavior I just don't understand. import SwiftUI import SwiftData struct ContentView: View { @Environment(\.modelContext) private var modelContext @Query ...
Torsten's user avatar
  • 25
0 votes
2 answers
316 views

Why can't I change the order of the model's array?

I'm currently programming my first SwiftData app. I created two models: Player.swift: @Model final class Player { @Relationship(inverse: \Game.players) var games: [Game] var name: String ...
scotland1912's user avatar