/***
 * Excerpted from "Xcode Treasures",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material,
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose.
 * Visit http://www.pragmaticprogrammer.com/titles/caxcode for more book information.
***/
//
//  ViewController.m
//  ExceptionBreakpointDemo
//
//  Created by Chris Adamson on 1/2/18.
//  Copyright © 2018 Subsequently & Furthermore, Inc. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property NSArray *members;
@end

@implementation ViewController


-(instancetype) initWithCoder:(NSCoder *)aDecoder {
  self = [super initWithCoder:aDecoder];
  self.members = @[@"Honoka", @"Kotori", @"Umi", @"Hanayo",
                   @"Rin", @"Maki", @"Nico", @"Nozomi", @"Eli"];
  return self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;
}

- (NSInteger) tableView:(UITableView *)tableView
  numberOfRowsInSection:(NSInteger)section {
  return self.members.count + 1; // bug!
}

- (UITableViewCell*) tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  UITableViewCell* cell = [tableView
                           dequeueReusableCellWithIdentifier:@"MemberCell"
                           forIndexPath:indexPath];
  cell.textLabel.text = self.members[indexPath.row];
  return cell;
}

@end
