ios - How do you know if a task executes in the background when your app sleeps? -


with objective c memory management, have general rule if create object of following techniques, need release object later.

  • alloc
  • new
  • copy
  • mutablecopy

this rule simple remember. i'm looking analogous simple rule deciding whether background processing when app sleeps. such definitive list exist?

  • nsurlrequest - if send request out hit home button right away, possible app still processes server response?
  • timer - set off timer fire 1 minute now, hit home button before 1 minute elapse. timer still run, paused, or canceled?
  • for loop - write loop million iterations. close app after it's done 600,000 iterations. happens rest of 400,000 iterations when app sleeps , when re-open app?
  • and on...

there's dozen other things i'm thinking whenever app sleeps. i'm worried because ever since started developing video camera app, battery life has been horrible (dropping 50% overnight). maybe it's coincidence or maybe camera still recording while app sleeping.

it depends on uibackgroundmodes flags in bundle extent. can use them tell ios want continue running in background. can dynamically request enough time continue download few minutes using beginbackgroundtaskwithexpirationhandler.

if nothing, default suspend app -- nstimers not fire until return foreground. if in loop on main thread, app little bit of time finish it, exact amount of time not specified. if loop on main thread takes long, app terminated if in foreground.

i'm not 100% sure happens nsurlconnections, suspect canceled default.

see:

iphoneos programming guide (pdf), p. 65

as battery issue, app responsible that. gps notorious battery hog, example, if continue run in background play audio or other processing.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -