Skip to main content

Questions tagged [swiftdata]

SwiftData is a Swift-based Apple framework for managed persistence. It combines CoreData persistence technology with Swift’s modern concurrency features.

swiftdata
0 votes
0 answers
12 views

fetchCount works but fetch doesn't

I am writing a function in my database object that can read from the database. I am storing vocab objects @Model final class Vocab: Codable{ var id: Int var word: String var meaning: ...
trsommer's user avatar
0 votes
0 answers
23 views

Saving and retrieving an image in SwiftData [closed]

I am saving a small image in a SwiftData model. It looks like I'm saving it successfully but not retrieving it properly to display in a SwiftUI view Here is where I save the image. I know I'm ...
David's user avatar
  • 287
-1 votes
0 answers
7 views

About CloudKit Security Roles and Permissions

I've checked that there are some questions like mine. But the terminology seems to have changed and it's been time, so I opened a new question. Hi, I'm trying to add the ability to back up and record ...
KimJitae's user avatar
  • 231
0 votes
1 answer
22 views

How do I do the equivalent of SELECT COUNT type of query in SwiftData on related data?

I have a model which is similar to: import Foundation import SwiftData import SwiftUI @Model final class AccountTransaction { var id: UUID = UUID() var name: String = "" var ...
Kenny Mann's user avatar
-1 votes
0 answers
34 views

Managing Shared ModelContext for Adding Items in SwiftUI from Both ContentView and Background Tasks

I’m working on Testing a SwiftUI project using SwiftData where I need to add Book objects to my model context from both the ContentView and a background task. I want to ensure that both operations use ...
Damiano Miazzi's user avatar
0 votes
1 answer
53 views

How to write Query with Predicate in SwiftUI detail view

I'm trying to write a @Query with a custom Predicate in a SwiftUI detail view. When I click items in the list the app hangs and memory usage increases linearly forever. If I put the predicate on the @...
Ezekiel's user avatar
  • 2,479
0 votes
1 answer
38 views

why my SwiftData Query freeze the ui , how to solve?

I wrote a simple Home view that uses a LazyVGrid to display all my playlists. The playlists are queried using SwiftData‘s @Query, but I have no idea why the UI freezes. There is only one playlist in ...
Damiano Miazzi's user avatar
0 votes
0 answers
30 views

Why is SwiftData @Query much slower with large datasets compared to FetchDescriptor?

I was load testing my app that lists some todos and essentially pre-populated database with 1000 records. This slowed things down in the app dramatically, tab switching felt sluggish and I pinpointed ...
Ilja's user avatar
  • 45.7k
0 votes
0 answers
71 views

How to manually listen for updates to a SwiftData @Model object?

Let's say I have a class like this: @Model final class MyItem: Identifiable { @Attribute(.unique) var id: String var name: String init(id: String, name: String) { self.id = id ...
SirRupertIII's user avatar
  • 12.5k
-4 votes
0 answers
39 views

Appending to array gives 'No exact matches in reference to static method 'buildExpression' [closed]

Trying to read a struct Array and build a array of class objects to be used in SWIFTDATA Model When appending the objects to the class array I get 'No exact matches in reference to static method '...
Robert A's user avatar
0 votes
0 answers
45 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
1 answer
48 views

Swift unexpected behaviour using SwiftData

With the code below: // // ContentView.swift // DataTest // // Created by Felipe Cruxen on 06/07/24. // import SwiftUI import SwiftData @Model class Director { var id: UUID = UUID() var ...
Felipe Cruxen's user avatar
0 votes
0 answers
28 views

How to get total records in SwiftData so can display the proper records or ContentUnavailableView (Custom or .search)

Watched Paul Hudson long SwiftData Tutorial and wanted to modify it by putting in the built-in ContentUnavailableView.search “No Search Results” view and also a custom “ContentUnavailableView” when ...
S. Hatmaker's user avatar
0 votes
0 answers
48 views

How to setup if-else in SwiftUI Views so can display the proper ContentUnavailableView (Custom or .search) [closed]

I was watching Paul Hudson - Hacking with Swift 2 hour plus video and followed everything fine. I have an OK understanding of SwiftUI but learning. The ContentView drives the creation and searching ...
S. Hatmaker's user avatar
1 vote
1 answer
87 views

SwiftData error on iOS 18, Never access a full future backing data

Try to update my app from iOS 17 to iOS 18. I'm using SwiftData to save the data on the memory. On iOS 17 all works fine, but I tried to export my app to iOS 18, and I get a strange error when I try ...
Damiano Miazzi's user avatar

15 30 50 per page
1
2 3 4 5
37