Created
October 9, 2014 17:18
-
-
Save premedios/16b038538ceb26384bbd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// SBViewController.m | |
// SearchBox | |
// | |
// Created by Pedro Remedios on 14/01/14. | |
// Copyright (c) 2014 Pedro Remedios. All rights reserved. | |
// | |
#import "SBViewController.h" | |
#import "ResultTableViewCell.h" | |
#import "SBSearchService.h" | |
@interface SBViewController () <SBSearchServiceDelegate> | |
{ | |
SBSearchService *searchService; | |
} | |
@end | |
@implementation SBViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
searchService = [[SBSearchService alloc] init]; | |
searchService.delegate = self; | |
[searchService search:@"mustang"]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (void)searchService:(SBSearchService *)searchService didFinishSearchingTerm:(NSString *)searchTerm withError:(NSError *)error { | |
[self.searchResultsTableView reloadData]; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | |
return (NSInteger)[[searchService resultData] count]; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
ResultTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"result cell" forIndexPath:indexPath]; | |
[cell configureForItem:[searchService resultData][(NSUInteger)indexPath.row]]; | |
return cell; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment