Skip to content

Instantly share code, notes, and snippets.

@nside
Created September 8, 2021 17:56
Show Gist options
  • Save nside/ef5af6fccfcbbf183ecaa0040c6f7917 to your computer and use it in GitHub Desktop.
Save nside/ef5af6fccfcbbf183ecaa0040c6f7917 to your computer and use it in GitHub Desktop.
Override application delegate on iOS with SDL2
// You can use this in your main.mm
#import "../SDL/include/SDL_uikitappdelegate.h"
@interface MyDelegate : SDLUIKitDelegate
@end
@implementation MyDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
BOOL ret = [super application:application didFinishLaunchingWithOptions:launchOptions];
NSLog(@"Owning the place!");
return ret;
}
@end
// Add a 'category' to the SDL app delegate class
@interface SDLUIKitDelegate (extra)
{
}
@end
@implementation SDLUIKitDelegate (extra)
+ (NSString *)getAppDelegateClassName {
return @"MyDelegate";
}
@end
@Cheaterman
Copy link

I wonder how to avoid XCode complaining on line 25, but otherwise this is very useful, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment