how to check if a property value exists in array of objects in swift

前端 未结 9 1641
执笔经年
执笔经年 2020-12-13 09:01

I am trying to check if a specific item (value of a property) exists in a array of objects, but could not find out any solution. Please let me know, what i am missing here.<

9条回答
  •  孤街浪徒
    2020-12-13 09:08

    signature:

    let booleanValue = 'propertie' in yourArray;
    

    example:

    let yourArray= ['1', '2', '3'];
    
    let contains = '2' in yourArray; => true
    let contains = '4' in yourArray; => false
    

提交回复
热议问题