]> git.saurik.com Git - uikittools.git/blob - uialert.mm
a72cbd4b41747a6403c918a89cd1cac458b5fda1
[uikittools.git] / uialert.mm
1 #include <UIKit/UIKit.h>
2 #include <unistd.h>
3
4 int argc_;
5 char **argv_;
6
7 @interface AlertSheet : UIApplication {
8 }
9
10 - (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button;
11 - (void) applicationDidFinishLaunching:(id)unused;
12 @end
13
14 @implementation AlertSheet
15
16 - (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
17 [sheet dismiss];
18 exit(button);
19 }
20
21 - (void) applicationDidFinishLaunching:(id)unused {
22 NSMutableArray *buttons = [NSMutableArray arrayWithCapacity:(argc_ - 3)];
23 for (size_t i(0); i != argc_ - 3; ++i)
24 [buttons addObject:[NSString stringWithCString:argv_[i + 3]]];
25
26 UIAlertSheet *sheet = [[[UIAlertSheet alloc]
27 initWithTitle:[NSString stringWithCString:argv_[1]]
28 buttons:buttons
29 defaultButtonIndex:0
30 delegate:self
31 context:self
32 ] autorelease];
33
34 [sheet setBodyText:[NSString stringWithCString:argv_[2]]];
35
36 [sheet setShowsOverSpringBoardAlerts:YES];
37 [sheet popupAlertAnimated:YES];
38 }
39
40 @end
41
42 int main(int argc, char *argv[]) {
43 argc_ = argc;
44 argv_ = argv;
45
46 char *args[] = {
47 "AlertSheet", NULL
48 };
49
50 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
51 UIApplicationMain(1, args, [AlertSheet class]);
52 [pool release];
53 return 0;
54 }