On 6 Aug 2009, at 17:48, Martin Kalbfuß wrote:

Some functions belong clearly to an object, like the bitmap functions for example. But I don't know whhere to put functions like SDL_init. Should I
create a library object or system object or something?

The best place for things like this is inside a +initialize method. On some object wrapping global SDL state, add this method:

+ (void)initialize
{
        // Protect from calls by subclass
        if (self != [SDLState class]) return;

        SDL_init();
        // Any other library initialization that you need.
}

This method will be called exactly once the first time the SDLState class receives. In order to instantiate the class, you send it an +alloc (or similar) message, so this will be called before the first time you create an instance of the class.

David

_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to