I have a view containing a number of UIButtons "Tom and Jerry", "The Lion King", etc. I want all of them to invoke the same action in my view controller, and then differentiate between the different buttons to get a button-specific NSString (e.g. identifiers like "TomJerry", "LionKing").
Ideas:
How best to achieve this? Any ideas, best-practices, implementation patterns?
Update: After reading the first answers (thanks!), I believe I should add some points for clarification.
All of the above approaches should work; point is, I don't particularly like any of them. I am asking you which of the approaches you would favor (and why), or whether there are other better approaches.
Further "requirements":
if (sender==self.button1) {…} else if (sender==self.button2) {…}
Added
An option would be to create a category of UIButton adding a method that returns an NSString based on the tag. You've still got the potential tag trouble but the tag-to-string conversion -- actual and conceptual -- is all in one place.
I believe this meets your original and further requirements.
Previously
Tags are fast and light, comparing two integers.
You can easily create a numbering scheme that keeps things cleanly separated: 1000-1999 is this type of thing, 1000-1099 is this subgroup, 1015 is an instance, etc.
Numeric comparisons are available: x.tag > 10000 do this.
Obviously, though, that means you have to track it and your code could end up difficult to parse down the road. Still, some nifty advantages.