我正在学习 Apple 的 SwiftUI 教程构建列表和导航 https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation#make-the-list-dynamic,我似乎找不到任何相关文档List
初始化器,或者identified(by:)
的方法Array
type:
struct LandmarkList: View {
var body: some View {
List(landmarkData.identified(by: \.id)) { landmark in
}
}
}
当我右键单击List
初始化程序并单击Jump to Definition
在 Xcode 中,它需要我这个初始化器 https://developer.apple.com/documentation/swiftui/list/3270228-init这是不对的。当我为identified(by:)
方法,它带我到这个奇怪的文件,它只有 13 行,没有提到identified(by:)
method:
我知道 Xcode 处于测试阶段,但我在哪里可以找到这些神秘代码的文档?到目前为止,该教程非常好,但我不确定这是什么List
and Array
是做。
identified
现在不再使用了。您可以尝试以下语法。
List{
ForEach(landmarkData, id: \.id) { landmark in
Text(landmark.placeName)
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)