As you all know, one of the most important new features of iOS 4 is multitasking. I just found out that the scaffold and demo projects I provided with Sparrow 0.9 had problems with multitasking — and this might be similar in your existing Sparrow projects.

Fortunately, the fix is extremely simple. All you have to do is open your application delegate (ApplicationDelegate.m) and update the contents of the following methods:

- (void)applicationWillResignActive:(UIApplication *)application
{
    [sparrowView stop];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [sparrowView start];
}

That’s it! Now your app should support multitasking.

I updated the Sparrow download package, so that the demo and scaffold projects use this code, too. I also included a small update of the atlas generator, so if you are using it, you can fetch that, too.

3 Responses to “Multitasking”

  1. Darko November 16, 2010 at 11:32 #

    But these methods are called earlier, then the above you mentioned, on iOS4

    applicationDidEnterBackground
    applicationWillEnterForeground

    when you arrive at

    applicationWillResignActive:

    there should be no OGL calls. So to stop Sparrow
    in this method might be to late!

    Do it in

    applicationDidEnterBackground -> Sparrow stop

    applicationWillEnterForeground -> Sparrow start

    Great framework! Thanks!

  2. Darko November 16, 2010 at 11:36 #

    Oh, I did a BIG mistake.

    Only applicationWillEnterForeground is called before
    applicationDidBecomeActive!

    So to stop sparrow it’s ok to do that in applicationWillResignActive

  3. den April 17, 2011 at 17:34 #

    also you need stop SPView before dealloc if you use few SPView in your project