A stored property cannot be named 'description'

In the code below a receive an error "A stored property cannot be named 'description'" . If I change the property "description" to "description1" the error is gone. I'am using Xcode 15b8. Anyone having the same problem

import Foundation

import SwiftData

@Model class Category {

var name: String
var description: String

init(name: String, description: String) {

    self.name = name
    self.description = description
}

}

  • I understand the reason behind this limitation but it is quite annoying / cumbersome when trying to integrate into existing APIs that use 「 description 」

Add a Comment

Accepted Reply

You can't name a Core Data attribute description because it conflicts with a method in the NSObject class. Currently SwiftData uses Core Data under the hood so the limitation also applies in SwiftData. See the following Stack Overflow question for more details:

https://stackoverflow.com/questions/4717519/why-cant-i-use-description-as-an-attribute-name-for-a-core-data-entity

Name your attribute something other than description.

Replies

You can't name a Core Data attribute description because it conflicts with a method in the NSObject class. Currently SwiftData uses Core Data under the hood so the limitation also applies in SwiftData. See the following Stack Overflow question for more details:

https://stackoverflow.com/questions/4717519/why-cant-i-use-description-as-an-attribute-name-for-a-core-data-entity

Name your attribute something other than description.