Apple官方SwiftUI教程运行报错
1、列表和导航教程中 SceneDelegate.swift错误
解决方法:修改SceneDelegate.swift 14行,使用LandmarkList不是LandmarkDetail
window.rootViewController = UIHostingController(rootView: LandmarkList())
2、处理用户输入教程中 预览错误
解决方法:取消对LandmarkDetail初始化程序的更改,只添加environmentObject(_ :)修饰符
struct LandmarkDetail_Preview: PreviewProvider {
static var previews: some View {
LandmarkDetail(landmark: landmarkData[0])
.environmentObject(UserData())
}
}