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
//DataManager.h | |
#import <Foundation/Foundation.h> | |
typedef void(^DataManagerDidGetData)(NSArray *json); | |
typedef void(^DataManagerDidError)(NSError *error); | |
@interface DataManager : NSObject | |
- (void)getData:(DataManagerDidGetData)complete error:(DataManagerDidError)error; |
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
- (void)reloadData { | |
[self.refreshControl beginRefreshing]; | |
//chamada em background | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
//requisição dos dados do servidor | |
NSError *err = nil; | |
NSArray *json = nil; | |
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:kURL]]; |
NewerOlder