Charles
Charles

Reputation: 11

iPhone App Gets Killed Before It Finishes Loading

Okay, so Apple apparently has this thing where if the app takes too long to load, iOS will automatically quit the app or something. So when I'm building my iPhone app, I have quite a few high resolution images, which take a while to load, and they never finish before the app is automatically killed. Can anyone help with this?

Thanks!

Upvotes: 1

Views: 504

Answers (3)

hotpaw2
hotpaw2

Reputation: 70693

which take a while to load ...

Not just app start up... If you want a responsive app, that app shouldn't do anything that takes more than a few dozens of milliseconds, synchronously, on the main UI thread or run loop.

Upvotes: 1

Kazuki Sakamoto
Kazuki Sakamoto

Reputation: 13999

As Alex said, I recommend you to load resources on a background thread. However, be careful to use UIKit on a background thread. For the most part, UIKit classes should be used only from an application’s main thread. You should use thread-safe API.

For example, UIImage +imageWithContentsOfFile: is thread-safe. UIImage +imageNamed: is not thread-safe.

(From Developer Forums thread)

Upvotes: 1

Alex Deem
Alex Deem

Reputation: 4805

From the iPhone Application Programming Guide: "Initialization time is not the time to start loading large data structures that you do not intend to use right away ... If your application requires additional time at launch to load data from the network or do other tasks that might be slow, you should get your interface up and running first and then launch the slow task on a background thread."

Upvotes: 9

Related Questions