diff --git a/src/SFML/Window/OSX/SFApplicationDelegate.h b/src/SFML/Window/OSX/SFApplicationDelegate.h index ed0fd1781..05f89cfe3 100644 --- a/src/SFML/Window/OSX/SFApplicationDelegate.h +++ b/src/SFML/Window/OSX/SFApplicationDelegate.h @@ -50,4 +50,10 @@ //////////////////////////////////////////////////////////// -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication; +//////////////////////////////////////////////////////////// +/// \brief Return a singleton instance of this class +/// +//////////////////////////////////////////////////////////// ++(id)instance; + @end diff --git a/src/SFML/Window/OSX/SFApplicationDelegate.m b/src/SFML/Window/OSX/SFApplicationDelegate.m index c22b720b8..b15678973 100644 --- a/src/SFML/Window/OSX/SFApplicationDelegate.m +++ b/src/SFML/Window/OSX/SFApplicationDelegate.m @@ -49,6 +49,14 @@ return YES; } +//////////////////////////////////////////////////////////// ++(id)instance +{ + static SFApplicationDelegate* singleton = nil; + if (singleton == nil) + singleton = [[SFApplicationDelegate alloc] init]; + return singleton; +} @end diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index 7d519462b..909146a26 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -139,7 +139,7 @@ void WindowImplCocoa::setUpProcess(void) // Register an application delegate if there is none if (![[SFApplication sharedApplication] delegate]) - [NSApp setDelegate:[[SFApplicationDelegate alloc] init]]; + [NSApp setDelegate:[SFApplicationDelegate instance]]; // Create menus for the application (before finishing launching!) [SFApplication setUpMenuBar];