Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (instancetype)init
  2. {
  3.     self = [super init];
  4.     if (self) {
  5.         self.transport = [[TransportLayer alloc] init];
  6.     }
  7.     return self;
  8. }
  9.  
  10. - (void)getObjectsWithCompletion:(void (^)(NSArray *, NSError *))completion {
  11.     [self.transport getDataWithURL:[NSURL URLWithString:@"http://www.mocky.io/v2/5964f18326000059183d75a7"]
  12.                         completion:^(NSArray *array, NSError *error) {
  13.                             if (error) {
  14.                                 completion ? completion(nil, error) : nil;
  15.                             } else {
  16.                                 NSMutableArray *items = [NSMutableArray array];
  17.                                 for (NSDictionary *item in array) {
  18.                                     Category *category = [[Category alloc] initWithJSON:item];
  19.                                     [items addObject:category];
  20.                                 }
  21.                                 completion ? completion(items, nil) : nil;
  22.                             }
  23.                         }];
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement