#ios
pod "PromiseKit", "~> 1.7.7"
- (PMKPromise *)testPromiseKit {
return [PMKPromise promiseWithAdapter:^(PMKAdapter adapter) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
adapter(@"YES", nil);
});
}];
}
- (void)testTakePromiseMethod {
[self testPromiseKit].then(^(NSString *str){
NSLog(@"test promise kit success: %@", str);
}).catch(^(NSError *error) {
NSLog(@"promise: %@",error.userInfo[NSLocalizedDescriptionKey]);
});
}