google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.8k stars 294 forks source link

Too many type arguments for class 'FBLPromise' (have 2, expected 1) #111

Closed hejunbinlan closed 5 years ago

hejunbinlan commented 5 years ago
ghost commented 5 years ago

Hi @hejunbinlan, in this case, the Promises' value would be an NSArray containing an NSData object and an NSURLResponse object. Here's an example.

shoumikhin commented 5 years ago

I.e. something like:

- (FBLPromise<NSArray *> *)fetchWithURL:(NSURL *)url {
  return [FBLPromise wrap2ObjectsOrErrorCompletion:^(FBLPromise2ObjectsOrErrorCompletion handler) {
    [NSURLSession.sharedSession dataTaskWithURL:url completionHandler:handler];
  }];
}

// ...

[[object fetchWithURL:...] then:^id(NSArray *result) {
  NSData *data = result.firstObject;
  NSURLResponse *response = result.lastObject;
  //...
}];