1

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) {
        print("yes")
    } else {
        print("no")
    } 

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

enter image description here

Anyone can help me,thanks in advance :|

1 Answer 1

1

You can use containsObject method for checking object exist in NSMutableArray

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

  if myArray.containsObject("one") {
     print("yes")
  } else {
    print("NO ")
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.