Ok, this is really really easy, but even though I went through 100s of tutorials, I still have no idea whats wrong with my app. All I want to do is just to display a table view, even empty, but I get a black screen on the simulator and an exception in the output too.
This is what I did (followed step by step a few tutorials):
- Open a view based app
-
This is my header:
@interface TableViewsViewController : UIViewController <UITableViewDelegate> { IBOutlet UITableView *tblSimpleTable; } @property (nonatomic, retain) IBOutlet UITableView *tblSimpleTable; @end -
did not do anything in .m besides synthesizing.
- IB: made 3 connections: delegate, dataSource, and tblSimpleTable to File’s owner.
Yes, I am a beginner, but this is ridiculous…appreciate any help. Thanks!
First off, a table view has two “delegate” types — the table view delegate and the table view data source. Your interface is being a delegate, but not a data source, for the table view.
If you add UITableViewDataSource to the interface, i.e.
and then compile, you’ll probably get errors about missing methods for number of sections and for cell. After you add these to your implementation, the table view should work.
My guess is the table view tries to ask your class for number of sections in the table, and since your class doesn’t actually respond to that selector, the code crashes.