AFNetworking 2.0 download multiple images with completion

后端 未结 3 376
再見小時候
再見小時候 2021-01-01 05:23

I\'m trying to figure out a way to download multiple images with AFNewtorking 2.0. I\'ve read a lot of posts here in SO, but can\'t find the answer I\'m looking for, hope yo

3条回答
  •  隐瞒了意图╮
    2021-01-01 06:24

    Try this:

    // _group, _queue are iVar variable
    dispatch_group_t *_group = dispatch_group_create();
    dispatch_queue_t *_queue = dispatch_queue_create("com.company.myqueue2", NULL);
    
    // all files download
    for(int i = 0 ; i < numberOfFileDownloads; i++){
       dispatch_group_async(_group, _queue, ^{
          // here is background thread;
          // download file
       });
    }
    
    
    // all files are download successfully, this method is called
    dispatch_group_notify(_group, _queue, ^{
    }
    

提交回复
热议问题