Created
February 12, 2017 01:53
-
-
Save malshash/12fd9cdba99b0888b1276c41dc0e7165 to your computer and use it in GitHub Desktop.
restkit example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - Network Accessibility Code | |
- (void)fetchData:(void(^)(void))completion { | |
[self prepareForFetch]; | |
RestClientSuccessBlock onSuccess = ^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { | |
NSDictionary *resultDict = [mappingResult dictionary]; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[self handleResponse:resultDict error:nil]; | |
[MBProgressHUD hideHUDForView:self.view animated:YES]; | |
if(completion) { | |
completion(); | |
} | |
}); | |
}; | |
RestClientFailureBlock onFailure = ^(RKObjectRequestOperation *operation, NSError *error) { | |
NSLog(@"Hit error: %@ with operation: %@", error.localizedDescription, operation); | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[MBProgressHUD hideHUDForView:self.view animated:YES]; | |
[self handleResponse:nil error:error]; | |
}); | |
}; | |
NSInteger offset = _currentPage * ListingLimit; | |
[[ListingsClient sharedInstance] fetchListingsWithLimit:ListingLimit offset:offset success:onSuccess failure:onFailure completion:completion]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment