How to check if an element is in an array

后端 未结 17 982
囚心锁ツ
囚心锁ツ 2020-11-22 10:24

In Swift, how can I check if an element exists in an array? Xcode does not have any suggestions for contain, include, or has, and a qu

17条回答
  •  逝去的感伤
    2020-11-22 11:07

    if user find particular array elements then use below code same as integer value.

    var arrelemnts = ["sachin", "test", "test1", "test3"]
    
     if arrelemnts.contains("test"){
        print("found")   }else{
        print("not found")   }
    

提交回复
热议问题