]> git.saurik.com Git - uikittools.git/commitdiff
First revision of uikittools.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 26 Feb 2008 09:02:03 +0000 (09:02 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 26 Feb 2008 09:02:03 +0000 (09:02 +0000)
makefile [new file with mode: 0644]
uialert.mm [new file with mode: 0644]

diff --git a/makefile b/makefile
new file mode 100644 (file)
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 (file)
index 0000000..a72cbd4
--- /dev/null
@@ -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;
+}