iOS Development

ios – Find out how to arrange a SwiftData + SwiftUI app with advanced fashions?

I’m a newbie in Swift. I’m attempting to construct a easy DnD Character sheet app. Right here is my simplified character mannequin.

ultimate class Character {
    var identify: String
    var hitDice: Cube

    init(identify: String, hitDice: Cube) {
        self.identify = identify
        self.hitDice = hitDice


class Cube {
    var quantity: Int
    var sides: Int

    init(_ quantity: Int, _ sides: Int) {
        self.quantity = quantity
        self.sides = sides


After I construct the app, I get this error: No actual matches in name to occasion methodology 'setValue'. This doesn’t solely occur with lessons. Additionally it is the case for dictionaries. Looks as if any non-primitive sort. Might this have one thing to do with how these knowledge sort map for underlying coredata/sqlite knowledge varieties?

Then I flip Cube into Mannequin

ultimate class Cube {
     // ...

The error goes away however I get this mysterious breakpoint

personal var _$backingData: any SwiftData.BackingData<Cube> = Cube.createBackingData()

public var persistentBackingData: any SwiftData.BackingData<Cube> {
    get {
    set {
        _$backingData = newValue

static var schemaMetadata: [SwiftData.Schema.PropertyMetadata] {
  return [
    SwiftData.Schema.PropertyMetadata(name: "number", keypath: Dice.number, defaultValue: nil, metadata: nil),
    SwiftData.Schema.PropertyMetadata(name: "sides", keypath: Dice.sides, defaultValue: nil, metadata: nil)

init(backingData: any SwiftData.BackingData<Cube>) {
  _number = _SwiftDataNoType()
  _sides = _SwiftDataNoType()
  self.persistentBackingData = backingData

personal let _$observationRegistrar = Statement.ObservationRegistrar()

struct _SwiftDataNoType {

My app

import SwiftUI
import SwiftData

struct CharacterSheetApp: App {
    let modelContainer: ModelContainer
    init() {
        do {
            modelContainer = strive ModelContainer(for: Character.self)
        } catch {
            fatalError("Couldn't initialize ModelContainer")

    var physique: some Scene {
        WindowGroup {

What am I doing improper?


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button