iOS: descargue el archivo solo si se modificó (NSURL y NSData)

Estoy descargando un montón de archivos de imagen de un servidor, y quiero asegurarme de que se descarguen solo si son más nuevos. Este método actualmente descarga las imágenes muy bien. Sin embargo, no quiero perder tiempo ni energía volviendo a descargar imágenes cada vez que el usuario inicie sesión en la aplicación. En su lugar, quiero descargar solo los archivos que A) No existen B) Son más nuevos en el servidor que en el dispositivo

Así es como estoy descargando las imágenes: * La url de la imagen se guarda en Core Data con el video al que está asociada. La url se genera usando un método de conversión simple que construyo (generaThumbnailURL)

-(void)saveThumbnails{
    NSManagedObjectContext *context = [self managedObjectContextThumbnails];
    NSError *error;
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription
                                   entityForName:@"Videos" inManagedObjectContext:context];
    [fetchRequest setEntity:entity];
    NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
    NSLog(@"Videos: %i",fetchedObjects.count);
    if (fetchedObjects.count!=0) {
        for(Videos *currentVideo in fetchedObjects){
            // Get an image from the URL below
            NSURL *thumbnailURL = [self generateThumbnailURL:[currentVideo.videoID intValue]];

            UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:thumbnailURL]];

            // Let's save the file into Document folder.
            // You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/)
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//Find Application's Document Directory
            NSString *documentsDirectory = [paths objectAtIndex:0];
            NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"DownloadedThumbnails"];
            //        NSString *dataPath = @"/Users/macminidemo/Desktop/gt";//DEBUG SAVING IMAGE BY SAVING TO DESKTOP FOLDER

            //Check if Sub-directory exists, if not, try to create it
            if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]){
                NSError* error;
                if([[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]){
                    NSLog(@"New Folder Created!");
                }
                else
                {
                    NSLog(@"[%@] ERROR: attempting to write create new directory", [self class]);
                    NSAssert( FALSE, @"Failed to create directory maybe out of disk space?");
                }
            }
            NSArray *splitFilename = [[self generateThumbnailFilename:[currentVideo.videoID intValue]] componentsSeparatedByString:@"."];//Break Filename Extension Off (not always PNGs)
            NSString *subString = [splitFilename objectAtIndex:0];
            NSString *formattedFilename = [NSString stringWithFormat:@"%@~ipad.png",subString];
            NSString *localFilePath = [dataPath stringByAppendingPathComponent:formattedFilename];
            NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
            [imageData writeToFile:localFilePath atomically:YES];
            NSLog(@"Image: %@ Saved!",formattedFilename);
        }
    }
}

Respuestas a la pregunta(2)

Su respuesta a la pregunta