Created
November 1, 2012 04:07
-
-
Save michaeldv/3991657 to your computer and use it in GitHub Desktop.
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 Alert | |
def initialize(title, message, *buttons) | |
# | |
# Delegating to self. | |
# | |
@alert = UIAlertView.alloc.initWithTitle(title, message:message, delegate:self, cancelButtonTitle:"Cancel", otherButtonTitles:"OK", nil) | |
@alert.show | |
self | |
end | |
# Never gets called... | |
def alertView(alertView, clickedButtonAtIndex:buttonIndex) | |
NSLog "clickedButtonAtIndex(#{buttonIndex})" | |
end | |
# Never gets called... | |
def alertView(alertView, didDismissWithButtonIndex:buttonIndex) | |
NSLog "didDismissWithButtonIndex(#{buttonIndex})" | |
end | |
end |
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 Alert | |
def initialize(title, message, *buttons) | |
# | |
# Delegating to self.class. | |
# | |
@alert = UIAlertView.alloc.initWithTitle(title, message:message, delegate:self.class, cancelButtonTitle:"Cancel", otherButtonTitles:"OK", nil) | |
@alert.show | |
self | |
end | |
def self.alertView(alertView, clickedButtonAtIndex:buttonIndex) | |
NSLog "clickedButtonAtIndex(#{buttonIndex})" | |
end | |
def self.alertView(alertView, didDismissWithButtonIndex:buttonIndex) | |
NSLog "didDismissWithButtonIndex(#{buttonIndex})" | |
end | |
end |
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 AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
alert = Alert.new("Title", "Message") | |
NSLog "alert: #{alert.inspect}" | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment