702 questions
0
votes
0
answers
15
views
Can I use a PersistentIdentifier hashValue for UserNotifications identifier?
In a SwiftUI project using SwiftData, local notifications typically use a UUID as the notification identifier. But, since I’m using SwiftData and want to avoid having multiple unique identifiers in my ...
-1
votes
0
answers
46
views
Why does my App freeze when declaring a State var of Type Date()?
I wanted to add a functionality to my App to store different Times (hour:minute) in an array of my SwiftData Model. And then to also add and remove items from this array. I ran into two problems.
The ...
0
votes
0
answers
30
views
Issues with Updating Widget Timeline Based on SwiftData/CoreData Changes in WatchOS App
I tried looking everywhere online and asked AI, but it seems none of the solutions resolved my issue. I am using CoreData or SwiftData with CloudKit to fetch data from the database. I created a simple ...
0
votes
1
answer
40
views
Syncing Issue Between iOS and WatchOS: SwiftData Not Updating on Watch
I decided to start practicing how to communicate data between iOS/iPad and WatchOS. It seems like it’s not syncing correctly because when I add or remove a person, my watch doesn’t update. I have two ...
-1
votes
1
answer
29
views
ModelActor and "Publishing background changes from background threads is not allowed" warning [closed]
I think my understanding of ModelActor is wrong...
I thought ModelActors are used to perform database actions that we don't want to run on the main thread and lock up the UI.
Are there any specific ...
0
votes
0
answers
50
views
Swift Date relationship, deleted object after after reopen app [duplicate]
i have issue with objects.I have models
@Model
class Tag {
var id: UUID
var title: String = ""
var color: Int = 0xFFFFFF
init( title: String, color: Int ) {
...
0
votes
1
answer
31
views
Can data be of persistence by just call context's method 'insert'? [closed]
I was trying to get data generated can be reload after App restarts. The method is insert of environment object 'modelContext'.
@Environment(\.modelContext) private var context
the data is an array ...
0
votes
0
answers
69
views
Publishing changes from background threads is not allowed warning [closed]
I have a SwiftData model that I am trying to update within a ModelActor. I have the complete concurrency check on (running Xcode Version 16.1 (16B40)) and I am seeing a warning "Publishing ...
0
votes
0
answers
40
views
SwiftData background processing rather than @MainActor
I am using SwiftData but am running in UI performance issues.
I found a nice article on how to perform all operations in the background:
Using ModelActor in SwiftData
It seems to make sense, but I am ...
0
votes
1
answer
45
views
What is the best way to check if a SwiftData model is updated in SwiftUI
I have a view hierarchy of SwiftUI objects and would like to efficiently update whenever the SwiftData object has changed. The issue I have is, I am using a isLoading flag to update certain properties ...
-1
votes
1
answer
83
views
SwiftData: adding a UUID to an existing model always creates the same id
I have a problem updating a SwiftData model by adding a property.
Specifically, I have the following model and I am trying to update it by adding an id. The problem is that, if I do this, all records ...
-1
votes
0
answers
35
views
How to track sync status with CloudKit/SwiftData in SwiftUI
I've setup CloudKit to work with my SwiftData app. Now my next hurdle is that when I reinstall the app, there is about a 1-2 second delay for all of my data to reappear. When app launches it shows as ...
0
votes
0
answers
64
views
Migrating SwiftData model with inverse relationship [closed]
I have a question I cannot find an answer for.
I am trying to migrate my SwiftData schema to a new version. Previously I had an unversioned schema, that I replicated in V1, then I made some ...
0
votes
1
answer
66
views
How to add enum field to my SwiftData model
I try to add an enum field to my model:
extension Item {
enum Diet: String, CaseIterable, Codable {
case herbivorous = "Herbivore"
case carnivorous = "Carnivore"...
-1
votes
0
answers
39
views
How to hot switch SwiftData model container?
I want to add switching SwiftData's work modes between local and iCloud. It's the basic cloud sync on/off logic.
I created a draft logic to do this:
@Observable
final class DataStore {
...