title: Set UITableView Delegate and DataSource
body: <p>This is my problem:
  I have this small <code>UITableView</code> in my storyboard:<img src="https://i.stack.imgur.com/msfw2.png" alt="enter image description here"></p>
  
  <p>And this is my code:</p>
  
  <p><strong>SmallTableViewController.h</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "SmallTable.h"
  
  @interface SmallViewController : UIViewController
  
  @property (weak, nonatomic) IBOutlet UITableView *myTable;
  
  @end
  </code></pre>
  
  <p><strong>SmallTableViewController.m</strong></p>
  
  <pre><code>#import "SmallViewController.h"
  
  @interface SmallViewController ()
  
  @end
  
  @implementation SmallViewController
  @synthesize myTable = _myTable;
  
  - (void)viewDidLoad
  {
      SmallTable *myTableDelegate = [[SmallTable alloc] init];
      [super viewDidLoad];
      [self.myTable setDelegate:myTableDelegate];
      [self.myTable setDataSource:myTableDelegate];
  
      // Do any additional setup after loading the view, typically from a nib.
  }
  
  - (void)viewDidUnload
  {
      [super viewDidUnload];
      // Release any retained subviews of the main view.
  }
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
      return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  }
  
  @end
  </code></pre>
  
  <p>Now as you can see, I want to set an instance called myTableDelegate as Delegate and DataSource of myTable.</p>
  
  <p>This is the Source of SmallTable class.</p>
  
  <p><strong>SmallTable.h</strong></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface SmallTable : NSObject &lt;UITableViewDelegate , UITableViewDataSource&gt;
  
  @end
  </code></pre>
  
  <p><strong>SmallTable.m</strong></p>
  
  <pre><code>@implementation SmallTable
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
      // Return the number of sections.
      return 0;
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      // Return the number of rows in the section.
      return 5;
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      // Configure the cell...
      cell.textLabel.text = @"Hello there!";
  
      return cell;
  }
  
  #pragma mark - Table view delegate
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSLog(@"Row pressed!!");
  }
  
  @end
  </code></pre>
  
  <p>I implemented all the <code>UITableViewDelegate</code> and <code>UITableViewDataSource</code> method that the app need. Why it just crash before the view appear??</p>
  
  <p>Thanks!!</p>