Drag out a UITableView and UITableViewCell

Screen Shot 2017-06-03 at 12.05.17 PM.png

Implement the source and delegate interfaces

Screen Shot 2017-06-03 at 12.06.03 PM.png

Connect the TableView outlet

Screen Shot 2017-06-03 at 12.09.38 PM.png

Give it some data

Screen Shot 2017-06-03 at 12.06.29 PM.png


Screen Shot 2017-06-03 at 12.06.58 PM.png



#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>



#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, strong) NSArray *tableData;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@implementation ViewController

- (void)viewDidLoad
    [super viewDidLoad];

    self.tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];

    self.tableView.delegate = self;
    self.tableView.dataSource = self;

// UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    return self.tableData.count;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    static NSString *simpleTableIdentifier = @"SimpleTableItem";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];

    cell.textLabel.text = [self.tableData objectAtIndex:indexPath.row];
    return cell;