summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-02-26 09:02:03 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2008-02-26 09:02:03 +0000
commita60b86de5fbe121d51d756c166eac49e1832e007 (patch)
tree04b9d08e65e9029f78c7c9f01daf58c5d3efafb9
First revision of uikittools.
-rw-r--r--makefile5
-rw-r--r--uialert.mm54
2 files changed, 59 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..83a4e00
--- /dev/null
+++ b/makefile
@@ -0,0 +1,5 @@
+all: uialert
+
+%: %.mm
+ arm-apple-darwin-g++ -o $@ $< -framework CoreFoundation -framework Foundation -framework UIKit -lobjc
+ arm-apple-darwin-strip $@
diff --git a/uialert.mm b/uialert.mm
new file mode 100644
index 0000000..a72cbd4
--- /dev/null
+++ b/uialert.mm
@@ -0,0 +1,54 @@
+#include <UIKit/UIKit.h>
+#include <unistd.h>
+
+int argc_;
+char **argv_;
+
+@interface AlertSheet : UIApplication {
+}
+
+- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button;
+- (void) applicationDidFinishLaunching:(id)unused;
+@end
+
+@implementation AlertSheet
+
+- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
+ [sheet dismiss];
+ exit(button);
+}
+
+- (void) applicationDidFinishLaunching:(id)unused {
+ NSMutableArray *buttons = [NSMutableArray arrayWithCapacity:(argc_ - 3)];
+ for (size_t i(0); i != argc_ - 3; ++i)
+ [buttons addObject:[NSString stringWithCString:argv_[i + 3]]];
+
+ UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+ initWithTitle:[NSString stringWithCString:argv_[1]]
+ buttons:buttons
+ defaultButtonIndex:0
+ delegate:self
+ context:self
+ ] autorelease];
+
+ [sheet setBodyText:[NSString stringWithCString:argv_[2]]];
+
+ [sheet setShowsOverSpringBoardAlerts:YES];
+ [sheet popupAlertAnimated:YES];
+}
+
+@end
+
+int main(int argc, char *argv[]) {
+ argc_ = argc;
+ argv_ = argv;
+
+ char *args[] = {
+ "AlertSheet", NULL
+ };
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ UIApplicationMain(1, args, [AlertSheet class]);
+ [pool release];
+ return 0;
+}