The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
extending SDL_uikitappdelegate and SDL_uikitviewcontroller i
m3xican


Joined: 07 Oct 2010
Posts: 21
Location: London, UK
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
extending SDL_uikitappdelegate and SDL_uikitviewcontroller i
Eric Wing
Guest

On 9/19/16, Davide Coppola wrote:
Quote:
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
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org