mercredi 15 juin 2016

Check if NSMutableArray contains a given value


I have an NSMutableArray that contains String values. I have a String variable and I want to check if it is contained in the array or not.

I tried using .contains() with String but it say:

Cannot convert value of type String to expected argument type...

var mutableArray = NSMutableArray()  // ["abc", "123"]
var string = "abc"

mutableArray.contains("abc") {       // above error in this line

}

Aucun commentaire:

Enregistrer un commentaire