Hi @azamsharp,I don't seem to see an answer to my doubt in the content you shared. Could you be more specific?
Post
Replies
Boosts
Views
Activity
Hi @azamsharp, sorry but I don't understand how this respond to my question. Your solution is valid when you create in a view a new object and after manipulate it you call save. What happens in edit, considering that SwiftData autosaves changes? What happens, If user edit BudgetCategory and change the name? How do you check that name already exists? Also, if for example you need to call another function only if the user confirms a change to the budget amount, how do you handle that?
@lucaszischka Works for me in beta 5. I use as reference the code here "https://developer.apple.com/videos/play/wwdc2023/10154/?time=564" (min 9:05), without the problem of main actor. So, I define MainActor PreviewContainer (like video) and in #Preview I have only ".modelContainer(previewContainer)" under View and use the solution of this topic for pass a preview static Item