I am using asynchronous NSURLConnection to upload my images. I have a minor requirement and I want to know what is the efficient way to achieve it. When I press upload button then I pop my current view controller, so what I need is my upload operation keeps going on background even if I am at any part of my navigation controller stack. I can navigate and be anywhere but still want that upload to happen in background.
I just need tips on what is the efficient and elegant way to achieve that.
You need to separate your uploading logic from the view controller that triggers it.
Perhaps you could create an “upload manager” class that handles all the uploads from different view controllers in a queue and just notifies the interested view controllers about things like progress, errors, etc. (e.g. via notifications).
It could then also manage background task identifiers for continuing uploads when your app is sent to the background by pressing the home button.