init(_:)
Creates an instance from content generated by a model.
Declaration
init(_ content: GeneratedContent) throwsDiscussion
Conformance to this protocol is provided by the @Generable macro. A manual implementation may be used to map values onto properties using different names. To manually initialize your type from generated content, decode the values as shown below:
struct Person: ConvertibleFromGeneratedContent {
var name: String
var age: Int
init(_ content: GeneratedContent) {
self.name = try content.value(forProperty: "firstName")
self.age = try content.value(forProperty: "ageInYears")
}
}