Block-based action handlers for UIActionSheet and UIAlertView
||Date Originated:||June 12th, 2012|
Implement the possibility of specifying a block for handling actions that are to be executed when selecting an action from a UIActionSheet or a button from an UIAlertView.
The traditional delegate model has several shortcomings that are causing code to be bloated and hard to maintain:
- the developer has to keep some sort of reference to the interacted element so that in the delegate callback the appropriate action can be carried out. This is quite cumbersome.
- if multiple action sheets are used from the same view controller the developer has to be able to tell apart the callbacks by e.g. setting a tag value for each. This invariably leads to large switch trees.
Many developers agree with this need, which is why there are so many implementations in existence that somehow graft blocks onto UIActionSheet or UIAlertView.
I've made a list or several such implementations here: http://www.cocoanetics.com/2012/06/block-based-action-sheet/
By implementing a way for developers to specify block-based action handlers the amount of code needed for complex interactions can be dramatically reduced because the action item state would be kept in the block as opposed to an IVAR or tag number.
Reports posted here will not necessarily be seen by Apple.
All problems should be submitted at bugreport.apple.com before they are posted here.
Please only post information for Radars that you have filed yourself, and please do
not include Apple confidential information in your posts. Thank you!