2019独角兽企业重金招聘Python工程师标准>>>
Swift
// MARK:// MARK: 获取数据/// 获取数据class func toolLoadData(completion:(finish: String) -> ()? ,content: String) {self .nextStepRequest({ (finish) -> ()? in// 接收到数据 调用 block 传递数据completion(finish: finish);}, content: "");}// MARK:// MARK: 下一步请求/// 下一步请求private class func nextStepRequest(completion:(finish: String) -> ()? ,content: String) {// 获取数据成功 调用block 传递数据completion(finish: "data");}
OC
/// 获取数据
+ (void)toolLoadData:(NSString *)content completion:(void (^)(NSString *finish))completion {[self nextStepRequest:@"" completion:^(NSString *finish) {// 调用 blockcompletion(finish);}];}/// 下一步请求
+ (void)nextStepRequest:(NSString *)other completion:(void (^)(NSString *finish))completion {completion(@"data");}
Swift和OC->Demo点此下载