title: responseBlock runs at the end of api call objective c
body: <p>I have to store specific movies url in database to show in collectionView which is inside a table cell. Whenever it compiles to this line <code>[API userMovies:catId getResponseBlock:^(id responseObject)</code> it goes to this line <code>_movieImages = [Movies MR_findAll]</code> instead of <code>responseBlock</code>.</p>
  
  <pre><code>- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    static int number = 0;
      catId = [[_movieCategories objectAtIndex:number] categoryId];
      number++;
      [API userMovies:catId getResponseBlock:^(id responseObject)
       {
           [Movies MR_truncateAll];
           [[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];     
           NSArray *responseArray = [responseObject objectForKey:@"items"];      
           [Movies MR_importFromArray:responseArray];
           [[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];      
       } forFailureBlock:^(id failureObject) {
           //             self.errorMsg.text = @"Failed to load movies!";
       }];
         _movieImages = [Movies MR_findAll];
      return _movieImages.count;
  }
  </code></pre>
  
  <p><strong>cellForItemAtIndexPath:</strong></p>
  
  <pre><code> - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  
          CategoryCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CatCell" forIndexPath:indexPath];
  
          NSURL *url = [NSURL URLWithString:[[_movieImages objectAtIndex:indexPath.row] cover_img]];
          NSNumber *rate = [[_movieImages objectAtIndex:indexPath.row]rating];
  
  
          [cell.imageView setImageWithURL:url];
          _categoryCollection.showsHorizontalScrollIndicator = NO;
  
          return cell;
      }
  </code></pre>
  
  <p><strong>cellForRowAtIndexPath:</strong></p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      static NSString *categoryTable = @"CategoryCell";
  
      // Configure the cell...
          CategoryMovieCell *cell = [tableView dequeueReusableCellWithIdentifier:categoryTable];
          cell.categoryMovie.text = [[_movieCategories objectAtIndex:(indexPath.row-1)] name];
          return cell;
  }
  </code></pre>