Mercurial > sdl-ios-xcode
comparison src/video/uikit/SDL_uikitappdelegate.m @ 5134:7b7da52e8775
Fixed spacing
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 08:59:22 -0800 |
parents | 2bb1bfeee9e2 |
children | 5f09cb749d75 |
comparison
equal
deleted
inserted
replaced
5133:ec13e48ee0d9 | 5134:7b7da52e8775 |
---|---|
35 static int forward_argc; | 35 static int forward_argc; |
36 static char **forward_argv; | 36 static char **forward_argv; |
37 | 37 |
38 int main(int argc, char **argv) { | 38 int main(int argc, char **argv) { |
39 | 39 |
40 int i; | 40 int i; |
41 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 41 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
42 | 42 |
43 /* store arguments */ | 43 /* store arguments */ |
44 forward_argc = argc; | 44 forward_argc = argc; |
45 forward_argv = (char **)malloc((argc+1) * sizeof(char *)); | 45 forward_argv = (char **)malloc((argc+1) * sizeof(char *)); |
46 for (i=0; i<argc; i++) { | 46 for (i=0; i<argc; i++) { |
47 forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); | 47 forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); |
48 strcpy(forward_argv[i], argv[i]); | 48 strcpy(forward_argv[i], argv[i]); |
49 } | 49 } |
50 forward_argv[i] = NULL; | 50 forward_argv[i] = NULL; |
51 | 51 |
52 /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ | 52 /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ |
53 UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate"); | 53 UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate"); |
54 | 54 |
55 [pool release]; | 55 [pool release]; |
56 | 56 |
57 } | 57 } |
58 | 58 |
59 @implementation SDLUIKitDelegate | 59 @implementation SDLUIKitDelegate |
60 | 60 |
61 /* convenience method */ | 61 /* convenience method */ |
62 +(SDLUIKitDelegate *)sharedAppDelegate { | 62 +(SDLUIKitDelegate *)sharedAppDelegate { |
63 /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */ | 63 /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */ |
64 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; | 64 return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate]; |
65 } | 65 } |
66 | 66 |
67 - (id)init { | 67 - (id)init { |
68 self = [super init]; | 68 self = [super init]; |
69 return self; | 69 return self; |
70 } | 70 } |
71 | 71 |
72 - (void)postFinishLaunch { | 72 - (void)postFinishLaunch { |
73 | 73 |
74 /* run the user's application, passing argc and argv */ | 74 /* run the user's application, passing argc and argv */ |
75 int exit_status = SDL_main(forward_argc, forward_argv); | 75 int exit_status = SDL_main(forward_argc, forward_argv); |
76 | 76 |
77 /* free the memory we used to hold copies of argc and argv */ | 77 /* free the memory we used to hold copies of argc and argv */ |
78 int i; | 78 int i; |
79 for (i=0; i<forward_argc; i++) { | 79 for (i=0; i<forward_argc; i++) { |
80 free(forward_argv[i]); | 80 free(forward_argv[i]); |
81 } | 81 } |
82 free(forward_argv); | 82 free(forward_argv); |
83 | 83 |
84 /* exit, passing the return status from the user's application */ | 84 /* exit, passing the return status from the user's application */ |
85 exit(exit_status); | 85 exit(exit_status); |
86 } | 86 } |
87 | 87 |
88 - (void)applicationDidFinishLaunching:(UIApplication *)application { | 88 - (void)applicationDidFinishLaunching:(UIApplication *)application { |
89 | 89 |
90 /* Set working directory to resource path */ | 90 /* Set working directory to resource path */ |
91 [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; | 91 [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; |
92 | 92 |
93 [self performSelector:@selector(postFinishLaunch) withObject:nil | 93 [self performSelector:@selector(postFinishLaunch) withObject:nil |
94 afterDelay:0.0]; | 94 afterDelay:0.0]; |
95 } | 95 } |
96 | 96 |
97 - (void)applicationWillTerminate:(UIApplication *)application { | 97 - (void)applicationWillTerminate:(UIApplication *)application { |
98 | 98 |
99 SDL_SendQuit(); | 99 SDL_SendQuit(); |
100 /* hack to prevent automatic termination. See SDL_uikitevents.m for details */ | 100 /* hack to prevent automatic termination. See SDL_uikitevents.m for details */ |
101 longjmp(*(jump_env()), 1); | 101 longjmp(*(jump_env()), 1); |
102 | |
103 } | 102 } |
104 | 103 |
105 - (void) applicationWillResignActive:(UIApplication*)application | 104 - (void) applicationWillResignActive:(UIApplication*)application |
106 { | 105 { |
107 //NSLog(@"%@", NSStringFromSelector(_cmd)); | 106 //NSLog(@"%@", NSStringFromSelector(_cmd)); |