Discussion:
[SDL] extending SDL_uikitappdelegate and SDL_uikitviewcontroller in iOS project
Davide Coppola
2016-09-19 12:55:49 UTC
Permalink
Hi,

I need to add functions to the App Delegate and View Controller of an iOS
game based on SDL 2.

Is there any way of doing it without changing the actual SDL code?

Basically what I need is doing something like extending SDLActivity in the
android project, but I can't find a way of doing it for the iOS one.

Thank you
Eric Wing
2016-09-21 02:40:02 UTC
Permalink
Post by Davide Coppola
Hi,
I need to add functions to the App Delegate and View Controller of an iOS
game based on SDL 2.
Is there any way of doing it without changing the actual SDL code?
Basically what I need is doing something like extending SDLActivity in the
android project, but I can't find a way of doing it for the iOS one.
Thank you
There may be other people who have actually done this with SDL, so I
hope they chime in, but in Objective-C, there is something called
"categories" where you can add new methods to an existing class
without needing access or modifying the original class.

So if you just need to add methods, then just use categories to add
your new methods.

Something like (typed in mail / not checked)


// SDL_uikitappdelegate+MyExtraMethods.m
@implementation SDL_uikitappdelegate (MyExtraMethods)

- (BOOL) myNewMethod1
{
return YES;
}

- (void) myNewMethod2
{
SDL_Log("do something");
}

@end

// SDL_uikitviewcontroller+MyExtraMethods.m
@implementation SDL_uikitviewcontroller (MyExtraMethods)

- (BOOL) myNewMethod1
{
return YES;
}

- (void) myNewMethod2
{
SDL_Log("do something");
}

@end

-Eric

Loading...