objective c - IOS: Is it possible preserve the State of UIViewController in Background -


am developing ios app. need make images upload server. using nsurlsession , uploadtaskwithrequest this. every thing working fine in normal way. requirement user wants store post more 10 images in app using database sqllite. , later show stored posts in uitableview button each uitableviewcell. when user tap on each button should start uploading each post server. thought should persist uiviewcontroller in appdelegate process of uploading should not killed when user go view controllers.

my problem: when user close app process in uiviewcontroller post uploading stoping. know how keep uiviewcontroller live in app go close or go background.

is there better way fulfill requirement.

here better ways!

  1. use singleton. in apps, i'll create class called "datahandler" handles of nsurlsession/coredata/etc stuff have is

    [datahandler uploadimages:images]; 

and when need information i'll call

    self.tabledata = [datahandler lastuploadedimages]; 

this way don't have worry if view controller still alive.

  1. have appdelegate nsurlsession stuff. know appdelegate persisted why not have guy it! here example:

    uiapplication *sharedapplication = [uiapplication sharedapplication]; appdelegate *appdelegate = [sharedapplication delegate]; // method add appdelegate.  make sure // import appdelegate's header file viewcontroller can // call method. [appdelegate uploadimages:images];  

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -