I’m creating an app for “asset catalog”. In my root view controller i maintain an array of those assets (instances of Asset class) as well as array of scroll view subviews which are paginated in that scroll view. Each of those subviews has a button which performs an action on an asset of same index as the page.
My question is – what’s the most unhacky way to know which page the button was clicked on?
Should I calculate page number from scroll view’s content offset or go to super view and get it’s index from scrollview subviews’ array?
I believe there are even better ways to do that without creating any anti-patterns or breaking mvc.
You have quite a lot of options here really.
If you already have all of the subviews in an array I’d loop through that array and assign each view the array index as its tag. That would be relatively straightforward and easy to manage.