我知道如何修复这个错误,但我的修复导致了另一个错误。
最初的问题如下
@Binding var report: Report
init(property: Property, report: Binding<Report>, saveAction: @escaping () -> Void) {
self.property = property
self.report = report // cannot assign value of type Binding<Report> to type Report
self.data = SpacesData(property: property, report: report)
self.saveAction = saveAction
}
如果我改成下面的
var report: Binding<Report>
init(property: Property, report: Binding<Report>, saveAction: @escaping () -> Void) {
self.property = property
self.report = report
self.data = SpacesData(property: property, report: report)
self.saveAction = saveAction
}
错误消失了,但我无法再调用报告中的方法。所以例如以下
let image = report.loadCoverImage(for: property)
抛出错误
<块引用>动态键路径成员查找不能引用实例方法 'loadCoverImage(for:)'