Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am doing something similar with a lot more images than 1000. I am storing the url's for the images in core data and then getting an <code>NSArray</code> of all the records where the record attribute <code>imageDownloaded = NO</code>. While downloading the images I set that record's <code>imageDownloaded = YES</code> so if the app needs to restart it can pick up where it left off.</p> <p>Here is a small example of whats happening. I am using Grand Central Dispatch to background this process so I am not blocking the main thread.</p> <pre><code>__block NSArray *records; //...get records dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; for (NSManagedObject *obj in records) { NSString *imageName = [obj valueForKey:@"filename"]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[obj valueForKey:@"remote_path"],imageName]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL]; [responseData writeToFile:[NSString stringWithFormat:@"%@/%@",documentsDirectory,imageName] atomically:NO]; [obj setValue:[NSNumber numberWithBool:YES] forKey:@"imageDownloaded"]; } }); </code></pre> <p>More Information on Grand Central Dispatch <a href="https://developer.apple.com/library/mac/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html" rel="nofollow">https://developer.apple.com/library/mac/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html</a></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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