Can I write @objc
field in Swift runtime or not?
This post says, I can, but not sure:
How to set a member variable value using reflection in Swift?
It says with @objc, reflection is possible in Swift, but in my code I can not assign, it raise error for me:
Value of type 'Organization' has no member 'setValue'
if let o = obj as? Organization {
o.setValue(value, forKey: key)
}
I applied @objc
for many field in Organization
. What is the problem?
final class Organization: Model, Content {
static let schema = "Organization"
@ID(custom: "id", generatedBy: .random)
var id: UUID?
@OptionalField(key: "fbId")
var fbId: String?
@OptionalField(key: "name")
@objc var name: String?
Aucun commentaire:
Enregistrer un commentaire