1

Looking for a way to check if an [[String]] array contains a value and then find the index of that value.

The [[String]] array is named: "categoriesArray" and contains three String arrays

Tried using .indexOf like below:

var location = categoriesArray.indexOf(array1)

But I get an error saying:

Cannot convert value of type '[String]' to expected argument type '([String]) throws -> Bool'

Anyone know how I can solve this?

2
  • 1
    What is roundLightArray? Commented Dec 14, 2017 at 22:02
  • @JosephK. Updated the question Commented Dec 14, 2017 at 22:04

1 Answer 1

1

indexOf or it newer version index(where:) takes closure as parameter, not an object you're looking for. Correct usage:

// index will return optional Int
var location = categoriesArray.index(where:{$0==roundLightArray})
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.