Skip to content

How to download photos concurrently #4

@JianBinWu

Description

@JianBinWu
for (NSNumber *number in self.selectedIndexPathRows) {
        NSInteger row = [number integerValue];
        DJIMediaFile *mediaFile = self.mediaList[row];
        __block NSUInteger previousOffset = 0;
        __block NSMutableData *fileData = nil;
        [mediaFile fetchFileDataWithOffset:previousOffset updateQueue:dispatch_get_main_queue() updateBlock:^(NSData * _Nullable data, BOOL isComplete, NSError * _Nullable error) {
            if (error) {
                DMLog(@"error---%@", error);
            }
            if (fileData == nil) {
                fileData = [data mutableCopy];
            }
            else {
                [fileData appendData:data];
            }
            previousOffset += data.length;
            float progress = previousOffset * 100.0 / mediaFile.fileSizeInBytes;
            DMLog(@"%@-------Downloading: %0.1f%%", mediaFile.fileName, progress);
            if (previousOffset == mediaFile.fileSizeInBytes && isComplete) {
                [target showPhotoWithData:fileData];
                [target savePhotoWithData:fileData];
            }
        }];
    }

I want to use this code to download photos concurrently, But I always get error, How can I do to download photos concurrently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions