learnig kid learnig kid - 1 year ago 108
Swift Question

ios Swift:How to compare object that existing in mutable array

Actually i'm new person for swift, this is my first project with swift.i have a problem faced that i cant compare the values with contains(),this is my code -- var str = "Dear"

if addstatus.contains(str) {
} else {

For this code it suggest a error ,pls find the screenshot

enter image description here

Anyone can help me,thanks in advance :|

Answer Source

You can use containsObject method for checking object exist in NSMutableArray

var myArray: NSMutableArray = ["one", "two", "three"]

  if myArray.containsObject("one") {
  } else {
    print("NO ")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download