Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>"I read on some threads that using subclasses were advantageous..."</p> </blockquote> <p>Using subclasses may be advantageous but that's not what you are doing here.</p> <p>What you have done is implemented an <code>(SDLApplication)</code> <a href="http://developer.apple.com/library/mac/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html#//apple_ref/doc/uid/TP40011210-CH6-SW2">Objective-C Category</a> on <code>NSApplication</code>. In that category, you are overriding <code>NSApplication</code>'s <code>terminate:</code> method. In general, you should use categories only to add additional methods to an existing class, not to override existing methods, as that can have unpredictable results.</p> <p>What you really should do is subclass <code>NSApplication</code> so that you can override <code>terminate:</code> properly:</p> <pre><code>@interface SDLApplication : NSApplication { } @end @implementation - (void)terminate:(id)sender { SDL_Event event; event.type = SDL_QUIT; SDL_PushEvent(&amp;event); [super terminate:sender]; // this line is the key to assuring proper behavior } @end </code></pre> <p>The last step in your overridden <code>terminate:</code> method should be a call to <code>super</code>, so that the terminate method works as it should. (Using the keyword <code>super</code> in a category is not allowed; only the word <code>self</code>, which is why there's a need for subclassing).</p> <p>Make sure you also change the value for the <code>NSPrincipalClass</code> key in your <code>Info.plist</code> file to be <code>SDLApplication</code> instead of <code>NSApplication</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload