0

I am trying to make a view that contains several tableViews in it - basically a week calendar view that each day is a tableView that shows the events of that day.

In the storyboard I'v added to the view a tableView and tried to connect it in two different ways in the viewDidLoad:

DaysTableViewController * tvc = [[DaysTableViewController alloc]  initWithStyle:UITableViewStylePlain];
self.dayView.delegate = tvc;
self.dayView.dataSource = tvc;

or:

DaysTableViewController * tvc = [[DaysTableViewController alloc] initWithStyle:UITableViewStylePlain];
self.dayView = tvc.tableView;

when dayView is my IBOutlet property for the tableView in the storyboard. but it crash in both ways, and I dont know where it crash in the code.

I know the DaysTableViewController itself works fine, because when I push it in a NavigationController it works.

Am I doing something wrong?

litov
  • 540
  • 5
  • 16

2 Answers2

2

You need to use TableViews inside a ViewController, not a TableViewController. A TVC can only have one tableview.

LJ Wilson
  • 14,445
  • 5
  • 38
  • 62
  • That's sort of not true. UITableViewControllers just conform to the delegate and datasource automatically. As for multiple tables, it's hard, but not impossible. – CodaFi Mar 22 '12 at 00:27
  • @CodaFi, I think what he means is that if you are using multiple tableviews at once, then you should put them into a UIViewController and not a UITableViewController, which is something I agree with. – sosborn Mar 22 '12 at 01:05
  • I am using a viewController, not a tableViewController. but I want the delegate and the dataSource to be in a different object. I tried to make an object that implement , and put it instead of DaysTableViewController, but it still crushed. when I put the same code in the main (week) ViewController it works fine. – litov Mar 22 '12 at 17:08
0

I'v found the problem. it was a simple memory management problem, I mad the Object that was the dataBase in the ViewDidLoad and didn't have a strong property for it, and just got released... thanks everyone for the answers.

litov
  • 540
  • 5
  • 16