Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
939
41
Tokyo, Japan
I am using a UIViewController with UITableView, it works good, I didn't define <UITableViewDelegate> or <UITableViewDataSource>, but I can use all methods of delegate and data resource.
I tried to find why I can use them, no result, can you tell me the simple reason, why?

Code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
 
The code works because the runtime successfully finds the required selectors.

The compiler has not been told that the class is compliant with the required protocols, and so you will see the warnings of the following form:

Code:
/path/to/Classes/RootViewController.m:89:0 /path/to/Classes/RootViewController.m:89: warning: class 'RootViewController' does not implement the 'UITableViewDelegate' protocol
 
The code works because the runtime successfully finds the required selectors.

The compiler has not been told that the class is compliant with the required protocols, and so you will see the warnings of the following form:

Code:
/path/to/Classes/RootViewController.m:89:0 /path/to/Classes/RootViewController.m:89: warning: class 'RootViewController' does not implement the 'UITableViewDelegate' protocol
The problem looks like ther is no such warning...
 
You probably only get the warning if you set the table's delegate and datasource in code. If you set it in IB then I think there will be no warning.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.