带有标识的 SwiftUI 列表初始值设定项(由 :) [英] SwiftUI List initializer with identified(by:)

查看:24
本文介绍了带有标识的 SwiftUI 列表初始值设定项(由 :)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习关于

我知道 Xcode 处于测试阶段,但我在哪里可以找到这些神秘代码的文档?到目前为止,本教程已经很棒了,但我不确定这个 ListArray 在做什么.

解决方案

identified 现在已不再使用.您可以尝试以下语法.

列表{ForEach(landmarkData, id: \.id) { 地标在文字(地标.地名)}}

I'm working through Apple's SwiftUI tutorial on building lists and navigation, and I can't seem to find any documentation for this List initializer, or the identified(by:) method of the Array type:

struct LandmarkList: View {
    var body: some View {
        List(landmarkData.identified(by: \.id)) { landmark in

        }
    }
}

When I right-click on the List initializer and click Jump to Definition in Xcode, it takes me to this initializer which isn't right. When I do the same for the identified(by:) method, it takes me to this strange file, which only has 13 lines and no mention of the identified(by:) method:

I know Xcode is in beta, but where can I find the documentation for these mysterious bits of code? The tutorial has been great up to this point, but I'm not certain what this List and Array are doing.

解决方案

identified is no more in use now. You may try below syntax.

List{
    ForEach(landmarkData, id: \.id) { landmark in
       Text(landmark.placeName)
    }
}

这篇关于带有标识的 SwiftUI 列表初始值设定项(由 :)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆