【问题标题】:How to get the index based on array values如何根据数组值获取索引
【发布时间】:2020-03-14 13:49:13
【问题描述】:

我有一个像“房子”这样的数组。每个房屋对象都有多个参数,例如 id、name、images、address。我在表格视图中显示所有这些。现在我有一个参数键名。

我必须循环进入我的房子数组,并找出包含在我的数组中的名称,我必须找出索引。

所以在我的表格视图中,我需要将特定的房屋项目滚动到顶部。

任何解决方案我该如何实现。

例如:Array - > [[id, name, image,address], [id, name, image,address], [id, name, image,address], [id, name, image,address]]

我只有一个键:“姓名”。

我必须循环进入我的数组并获取索引,这样我才能滚动到那个特定的索引。

谢谢

【问题讨论】:

    标签: ios swift xcode uitableview


    【解决方案1】:

    您可以使用 swift 中的 firstIndexOf 和 lastIndexOf 函数。您可以在How to find index of list item in Swift?找到详细信息

    【讨论】:

      猜你喜欢
      • 2017-03-17
      • 1970-01-01
      • 2013-01-02
      • 2011-11-29
      • 1970-01-01
      • 2022-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多