How to find index of list item in Swift?

后端 未结 22 1623
离开以前
离开以前 2020-11-22 06:17

I am trying to find an item index by searching a list. Does anybody know how to do that?

I see there is list.StartIndex and <

22条回答
  •  灰色年华
    2020-11-22 06:39

    If you are still working in Swift 1.x

    then try,

    let testArray = ["A","B","C"]
    
    let indexOfA = find(testArray, "A") 
    let indexOfB = find(testArray, "B")
    let indexOfC = find(testArray, "C")
    

提交回复
热议问题