All Questions
14
questions
-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 ...
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:
...
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 ...
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.
...
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 ...
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 ...
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() {
...
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 ...
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 ...
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 ...
-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 ...
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 ...
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 ...
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
...