Adds placeholder monsters to search view.
Adds navigation from search view to monster detail view.
This commit is contained in:
		| @@ -58,6 +58,10 @@ | ||||
|                                     </tableViewCell> | ||||
|                                 </prototypes> | ||||
|                                 <sections/> | ||||
|                                 <connections> | ||||
|                                     <outlet property="dataSource" destination="IwG-ax-Esn" id="3Ya-Rh-Hn4"/> | ||||
|                                     <outlet property="delegate" destination="IwG-ax-Esn" id="0MV-S6-Rtx"/> | ||||
|                                 </connections> | ||||
|                             </tableView> | ||||
|                         </subviews> | ||||
|                         <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||||
| @@ -79,6 +83,8 @@ | ||||
|                     </view> | ||||
|                     <tabBarItem key="tabBarItem" title="Search" image="magnifyingglass" catalog="system" id="BbH-jq-PCM"/> | ||||
|                     <connections> | ||||
|                         <outlet property="searchBar" destination="hhy-IY-MGR" id="G2a-h9-e8z"/> | ||||
|                         <outlet property="searchResults" destination="43I-Fg-55Z" id="chP-zW-RKH"/> | ||||
|                         <segue destination="qLX-b5-SkZ" kind="presentation" identifier="ShowMonsterDetail" id="kbb-pI-zWM"/> | ||||
|                     </connections> | ||||
|                 </viewController> | ||||
|   | ||||
| @@ -8,15 +8,28 @@ | ||||
|  | ||||
| #import "SearchViewController.h" | ||||
| #import "MonsterViewController.h" | ||||
| #import "Monster.h" | ||||
|  | ||||
| @interface SearchViewController () | ||||
|  | ||||
| @end | ||||
|  | ||||
| @implementation SearchViewController | ||||
| @implementation SearchViewController { | ||||
|     NSMutableArray *_monsters; | ||||
| } | ||||
|  | ||||
| - (void)viewDidLoad { | ||||
|     [super viewDidLoad]; | ||||
|     _searchBar.text = @"Hello, World!"; | ||||
|     _monsters = [[NSMutableArray alloc] init]; | ||||
|     Monster *monster; | ||||
|     monster = [[Monster alloc] init]; | ||||
|     monster.name = @"Pixie"; | ||||
|     [_monsters addObject:monster]; | ||||
|     monster = [[Monster alloc] init]; | ||||
|     monster.name = @"Acolyte"; | ||||
|     [_monsters addObject:monster]; | ||||
|  | ||||
|     // Do any additional setup after loading the view. | ||||
| } | ||||
|  | ||||
| @@ -30,4 +43,33 @@ | ||||
| } | ||||
| */ | ||||
|  | ||||
| #pragma mark - UITableViewDataSource | ||||
|  | ||||
| - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { | ||||
|     return [_monsters count]; | ||||
| } | ||||
|  | ||||
| - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { | ||||
|     static NSString *simpleTableIdentifier = @"SimpleTableItem"; | ||||
|      | ||||
|     UITableViewCell *cell = [_searchResults dequeueReusableCellWithIdentifier:simpleTableIdentifier]; | ||||
|      | ||||
|     if (cell == nil) { | ||||
|         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; | ||||
|     } | ||||
|      | ||||
|     cell.textLabel.text = ((Monster*)[_monsters objectAtIndex:indexPath.row]).name; | ||||
|      | ||||
|     return cell; | ||||
| } | ||||
|  | ||||
| #pragma mark - UITableViewDelegate | ||||
|  | ||||
| // Tap on table Row | ||||
| - (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { | ||||
|      | ||||
|     [self performSegueWithIdentifier:@"ShowMonsterDetail" sender:self]; | ||||
| } | ||||
|  | ||||
|  | ||||
| @end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user