Block-based action handlers for UIActionSheet and UIAlertView

Originator:oliver.drobnik
Number:rdar://11695432 Date Originated:June 12th, 2012
Status:Duplicate/11510636 Resolved:
Product:iPhone SDK Product Version:5.0
Classification:Enhancement Reproducible:N/A
 
Summary:

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.

Reasoning:

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/

Benefit:

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.

Comments

+1

Much needed improvement

+1

I also totally agree. This is much needed and simple addition.

By francois.proulx at June 25, 2012, 7:45 p.m. (reply...)

+1

I also would like this to be implemented.

By agoncalves at June 19, 2012, 9:34 a.m. (reply...)

Please note: 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!