turky
turky

Reputation: 5

How to get the index based on array values

I have one array like "house". Each house object has multiple parameters like id, name, images, address. And i am showing all these in table view. Now i have one parameter key name.

I have to loop in to my house array , and find out the name which is contain in my array and i have to find out the Index.

So that in my table view i need to scroll that particular house item to top.

Any solution how can i achieve that.

Eg: Array - > [[id, name, image,address], [id, name, image,address], [id, name, image,address], [id, name, image,address]]

I have one key : "name".

I have to loop in to my array and get the index, so that i can scroll to that particular index.

Thanks

Upvotes: 0

Views: 40

Answers (1)

You can use the functions firstIndexOf and lastIndexOf functions available in swift. You can find details on How to find index of list item in Swift?

Upvotes: 1

Related Questions