Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, this is what I mentioned <a href="https://stackoverflow.com/questions/6027119/nsurlconnection-download-multiple-images/6027275#6027275">in my comment</a>. Each time <code>connectionDidFinishLoading:</code> is called, you've got the result of just <em>one</em> connection. If you loop through all the file names, you will write that same chunk of data out to all those names, repeatedly. Each time through the for loop in <code>parsingComplete:</code> you create a new connection, get a new data object, and then write that same object out multiple times. After the end of the <code>parsing...</code> loop, you're left with a list of files all with the data from the last connection.</p> <p><sub>I'm pretty tired and I'm not sure: am I being clear?</sub></p> <hr> <p>Addressing your comment:</p> <p>You'll either have to make the correct file name for the current connection available to the delegate methods, probably by putting it in an ivar, or go the synchronous route. Putting in it in some ivar like <code>currFileName</code> so that all the methods in this class can access it is probably the least painless way to get the job done.</p> <pre><code>/* In parsingCompleted: */ for (int x = 0; x &lt; [catArray count]; x++) { /* download each file to the corresponding category sub-directory */ // fileOut is an instance variable fileOut = [NSString stringWithFormat:@"%@/%@_0%i.jpg",cat,catName,x]; imageRequest = [NSURLRequest etc... </code></pre> <hr> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection { // No loop; just use that file name that you set up earlier; // it correctly corresponds to the current NSURLConnection [receivedData writeToFile:fileOut atomically:YES]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload