Quitting Application & Open Files

Discussion in 'iOS Programming' started by neil.b, Dec 10, 2008.

  1. macrumors member


    Nov 20, 2008
    I've got the AudioQueue stuff working to play sound in my application but I'm wondering what happens to all the opened audio files if the user quits the app using the home button, for example.

    Do the open files get automatically closed?

    What about audio buffers etc?

    If I have to do manual cleaning up on exit, where do you do the cleaning up? I set a breakpoint in the dealloc method in my sound class but it doesn't seem to get called when the app is forced to quit (via the home button).
  2. Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Normally this is done in applicationWillTerminate: in your application delegate.
  3. macrumors 604

    Jul 29, 2003
    Silicon Valley
    The OS mops up everything on termination, but it's often cleaner for your app to clean up the way you want in the applicationWillTerminate delegate.

    It's also better for writing clean code and for debugging if you can account for everything in your termination delegate. e.g. if there's something you haven't closed or deallocated, it's a potential leak, etc.

  4. thread starter macrumors member


    Nov 20, 2008

Share This Page