Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell ID

I just started programming in Swift for iOS and I want to make an app with a table view and a search bar. When you click on a cell there will be played a sound. But when I search, I can't simply use indexPath.row because another song wil be played.

Is it possible to give every UITableViewCell an identifier so I can call a sound by the identifier of the tapped cell?

like image 388
Joep Avatar asked Nov 27 '25 23:11

Joep


1 Answers

When you search, you should ideally have another array storing the search results.

Lets say you have 10 cells.

You will have an array of 10 sounds which you will play based on indexPath.row

And you will also have another searchResultsArray which you are using to display the search results.

So, whenever didSelectRow is called, use the new array, and play sound from that array.

like image 81
Kakshil Shah Avatar answered Nov 30 '25 14:11

Kakshil Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!