I have a View Controller or a View that implements delegate and dataSource methods of UITableView.These methods are not going to be used outside this class.So is it a good idea to make the declaration of the UITableViewDataSource and UITableViewDelegate inside the .m file with a private category?For example :Instead of doing this:MyViewController.h@interface MyViewController:UIViewController<UITableViewDataSource,UITableViewDelegate>{}@endI put the declaration in the private category inside as there is no need for other objects to know whether my View Controller uses a TableView or not.MyViewController.m@interface MyViewController()<UITableViewDataSource,UITableViewDelegate>@endand Implementation in the .m file being the same in both the cases.
Is it a good idea to put declaration of protocols for delegates in a private category interface?
object oriented design;objective c
So is it a good idea to make the declaration of the  UITableViewDataSource and UITableViewDelegate inside the .m file with  a private category?That depends. Is the fact that MyViewController these protocols a private implementation detail, or something that you want to communicate to anyone using the class?Header files are there to communicate your class's public interface, not just to the compiler but also to anyone using the class. If you would include the fact that your class implements a given protocol in the written documentation, then you should declare the use of the protocol in the header. If you wouldn't put that in the docs, and instead want to send the message that nobody should count on the class implementing that protocol, put it in the implementation file.