[SDL] extending SDL_uikitappdelegate and SDL_uikitviewcontroller in iOS project

Eric Wing ewmailing at gmail.com
Tue Sep 20 19:40:02 PDT 2016


On 9/19/16, Davide Coppola <vivaladav at gmail.com> wrote:
> 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


More information about the SDL mailing list