Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. .h
  2.  
  3. @interface ICSessionManager (CheckAPI)
  4.  
  5. - (nullable NSURLSessionDataTask *)checkAPIConnection:(nullable void (^)(void))successBlock
  6. failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failureBlock;
  7.  
  8. @end
  9.  
  10.  
  11. .m
  12. @implementation ICSessionManager (CheckAPI)
  13.  
  14. - (nullable NSURLSessionDataTask *)checkAPIConnection:(nullable void (^)(void))successBlock
  15. failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failureBlock {
  16.  
  17. return [self GET:ICTestAPI
  18. parameters:nil
  19. success:^( NSURLSessionDataTask * _Nullable task, id responseObject) {
  20. if (successBlock) {
  21. dispatch_async(dispatch_get_main_queue(), ^{
  22. successBlock();
  23. });
  24. }
  25. } failure:[ICSessionManager forwardFailureBlock:failureBlock]];
  26. }
  27.  
  28. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement