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