class SugarCube::AlertViewDelegate
Attributes
on_cancel[RW]
on_default[RW]
on_success[RW]
Public Instance Methods
alertView(alert, didDismissWithButtonIndex:index)
click to toggle source
# File lib/ios/sugarcube-factories/uialertview.rb, line 114 def alertView(alert, didDismissWithButtonIndex:index) handler = nil if index == alert.cancelButtonIndex handler = on_cancel else handler = on_success end handler ||= on_default args = nil if handler if handler.arity == 0 args = [] else # construct all the possible arguments you could send args = [buttons[index]] # add the first input if this is not the default if alert.alertViewStyle != UIAlertViewStyleDefault args << alert.textFieldAtIndex(0).text end # add the second one if this is a login+password input if alert.alertViewStyle == UIAlertViewStyleLoginAndPasswordInput args << alert.textFieldAtIndex(1).text end # and maybe you want the index, too args << index # but only send the ones they asked for args = args[0...handler.arity] end handler.call(*args) end self.send(:autorelease) end