Post

Replies

Boosts

Views

Activity

Deleting Production Database SwiftData
Hi all, I have setup my app to use SwiftData with CloudKit sync. I have a production environment and development environment. I can reset the development environment for myself and all users in CloudKit console, but I can't reset the production one as it's tried to users' iCloud accounts, so I've added a button in-app for that feature. In the onboarding of my app, I pre-seed the DB with some default objects, which should be persisted between app install. The issue I'm running into is that I'm unable to force-pull these models from iCloud during the onboarding of a clean re-install, which leads to the models later appearing as duplicates once the user has been on the app for a few minutes and it has pulled from their iCloud account. If anyone has any suggestions on how to handle this issue, I would greatly appreciate it.
2
0
205
3w
SwiftUI Textfield Input Lag with SwiftData Object
Hi, I have the following setup in SwiftUI: struct SetGroupView: View { @Bindable var setGroup: ExerciseSetGroup var body: some View { List { ForEach(setGroup.sets!) { set in SetRowView(set: set) } } } } struct SetRowView: View { @Bindable var set: ExerciseSet var body: some View { TextField("0", value: $set.weight, format: .number) } } ExerciseSetGroup and ExerciseSet are @Model objects which I am using with SwiftData. The problem is that any kind of editing within the textfield is very laggy, which I assume is caused by binding the value to the model itself. I have tested various approaches, including adding @State properties to the SetRowView to bind to the textfield instead. However, in this approach I need to manually update the SwiftData model, which again leads to lag when scrolling the list. My question is, is this performance issue something that just happens with SwiftData and is there any way to avoid it / fix it? The code I have given is simplified, but I debugged my code and pinpointed the performance issue down to this setup. I would appreciate any help, thanks.
3
0
1.2k
Mar ’24