Ilja
Ilja

Reputation: 46479

Determining if assets need to be re-cached in memory

Assume a game app, where user loads some contents into memory during first open. Afterwards they can:

  1. Move app into background
  2. Lock device
  3. Close app completely
  4. Get a phone call
  5. etc...

Is there a way to know when our app's contents are no longer in memory or something of similar sorts to determine when re-caching of assets is required?

I studied few game apps and they tend to do one of the following

  1. Show loading screen every time app comes back from background
  2. Show loading screen only if device was locked or closed (app is still in the background)

And I'm interested in achieving no.2 to not show loading screens unnecessarily each time app comes back from the background.

Upvotes: 1

Views: 248

Answers (1)

Eysner
Eysner

Reputation: 624

You can use AppDelegate method applicationWillTerminate
https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623111-applicationwillterminate

And notification willTerminateNotification https://developer.apple.com/documentation/uikit/uiapplication/1623061-willterminatenotification

If Application not terminate you don't need show any loading screen.

Upvotes: 1

Related Questions