Created
May 8, 2012 22:09
-
-
Save mjmsmith/2639802 to your computer and use it in GitHub Desktop.
playing with RubyMotion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BlockAlert | |
def initWithTitle(title, message:message) | |
@alert = UIAlertView.alloc.initWithTitle(title, message:message, delegate:self, cancelButtonTitle:nil, otherButtonTitles:nil) | |
@blocks = [] | |
self | |
end | |
def show | |
@alert.show() | |
end | |
def dismissAnimated(animated) | |
@alert.dismissWithClickedButtonIndex(-1, animated:animated) | |
end | |
def addButtonWithTitle(title, block:block) | |
block = lambda {} if !block | |
@alert.addButtonWithTitle(title) | |
@blocks << block | |
end | |
def alertView(alertView, didDismissWithButtonIndex:buttonIndex) | |
if buttonIndex >= 0 && buttonIndex < @blocks.size | |
@blocks[buttonIndex].call() | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment