-1

For my needs in my app what I need is store id object in each button and not to be relying on buttonIndex. I've no idea how can I do it.

Any ideas?

Idan Moshe
  • 1,955
  • 4
  • 26
  • 64

1 Answers1

0

Normally I would suggest subclassing UIButton to store whatever "id" object you want, but we don't have access to the internals of "UIActionSheet". It's always using non-subclassable buttons. You'll have to store a separate NSArray of "id" objects and use the button index to refer to the object in your separate NSArray.

B.T.W., UIAlertController is deprecated as of iOS 8, in favor of using the new UIAlertController class. And you can set up UIAlertActions with buttons that correspond to title and a "handler:" block (i.e. you could store your "id" object in the handler).

Michael Dautermann
  • 86,557
  • 17
  • 155
  • 196