Taking photos in order

Discussion in 'iOS Programming' started by erdinc27, Jun 24, 2018.

  1. erdinc27 macrumors regular

    Jul 20, 2011
    Hello guys. I develop an application and I need to take photos of some documents. Then I send this photos to server. If the upload operation is successful then I display that photo in a collection view. The problem is if the user takes another photo before the previous one's upload process completed then the upload process restart and the previous photo can not be uploaded. How can I upload photos one by one even if it is taken very fast? NSOperationQueue is good to use for that?
  2. grandM macrumors 65816


    Oct 14, 2013
    May I ask why you would wait for the photo to be shown till the upload was completed? Anyhow you are right that you need a kind of asynchronous method/class. In the on completion handler you can add the photo to your collection view. Mind you must go back to the main thread to change the collection view. Note you are not sure about the order working with asynchronous requests.
  3. erdinc27 thread starter macrumors regular

    Jul 20, 2011
    @grandM thank you for your answer. Let me clear the last situation of the problem. When the user takes a photo of document then I put that photo to classify by using ML then I send that image to server. These two process takes long time. What I want to do is to display the image in the collection view after it is classified by ML and then send it to the server. To achive that I created NSOperationQueue and then I create an NSOperation every time a photo is taken. But the problem is that if the user takes lets say 15 photo very fast then 9-10 photo is displayed the rest is lost. How can I manageto send all taken photos -15 in this case- to send ML to classify it ?
  4. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    I worked on a camera app a number of years ago. We found that the devices current at that time couldn't hold in memory more than a few camera size photos. What the app did was to throttle the camera so the user could only take a small number of photos and then while they were being processed the camera was unavailable.

    I don't think you've clearly explained what the problem is. Why do you lose photos? If it's memory related you could write the photos to disk and then upload from disk. You might also be able to downsize the images. If it's something else you need to figure out what that is.

Share This Page