The second type of Radar I vowed to be filing more of following WWDC 2012 are so called “Enhancement Requests”. I have yet to see any of my previously filed requests be implemented in iOS, but it never hurts. One Apple representative once told me that “we’ll implement it if enough people want it”.
I recently demonstrated in a tutorial how to add block-support to UIActionSheet. Now here’s the formal feature request suggesting to Apple to implement this in the official SDK.
The following is filed as Radar #11695432 and also added to OpenRadar.
Block-based action handlers for UIActionSheet and UIAlertView
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.
Categories: Bug Reports