简体   繁体   中英

Creating a block with two async requests and a completion

I am trying to make this block.

+ (void)getUsersAndTracksWithSearch:(NSString *)search withCompletion:(void(^)(NSMutableArray *users, NSMutableArray *tracks)) completion
{

}

I am using SoundCloud API. I am using their API method for getting a list of tracks and users. which is:

 [SCRequest performMethod:SCRequestMethodGET
                  onResource:[NSURL URLWithString:userURL]
             usingParameters:nil
                 withAccount:nil
      sendingProgressHandler:nil
             responseHandler:^(NSURLResponse *response, NSData *data, NSError *error)
     {
     })];

I am using this method twice and getting two responses, so how should I set up a block so that on completion of the block I have both responses?

Thanks

看一下NSOperationQueue,它可以以链接其操作(即链接其块)的方式使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM