Get the index of an object from a collection

In my UIViewController, I have an output collection:

@IBOutlet var cardButtons: Array<UIButton>

      

Create this collection. I want to get the index of an object, but Array doesn't have a suitable method for this. I found that the indexOfObject method is only found in NSArray.

Now I have passed the cardButtons property to NSArray

var cardButtonsArray = cardButtons as NSArray

      

and that solves my problem, but maybe there is another, cleaner way to do it?

Thank you for your help.

+3


source to share





All Articles