I am trying to update data in SwiftData. The documentation, however, is literally just:
func update(expressions: [String : NSExpression],
model: any PersistentModel.Type,
where predicate: NSPredicate? = nil) throws -> Bool
As a new developer, I have no clue what most of this means or how to use it. My code is below:
try? context.update(expressions ["teamScores":NSExpression(format: "\(teamScores)")], model: CounterModel.self)
It failed with exception of type NSException
.
I haven't been able to try much, honestly. With such a new framework having literally been released 6 days ago as of writing this, there isn't much documentation or examples outside of setting up the model, persisting data, and querying the database.