After some digging I found out that SwiftData is causing the problem. More concrete relationships
I have a class Account with has (optional) categories
@Relationship(deleteRule: .cascade, inverse: \Category.account)
var _categories: [Category]?
var categories: [Category] {
self._categories ?? []
}
in the class Category I have the a simple account variable
var account: Account
The application crahses when I use the following init function in Account (at the last line)
init(id: Int,
income: Bool,
location: String,
maintainance: Bool,
special: Bool,
taxRate: Float,
tenant: String,
title: String) {
self.id = id
self.income = income
self.location = location
self.maintainance = maintainance
self.special = special
self.taxRate = taxRate
self.tenant = tenant
self.title = title
self._categories = []
}
or when I use those lines
// category not found, so create one
let category: Category = Category(title: categoryName, account: self)
if self._categories == nil {
self._categories = [category]
}
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: