What is the benefit of declaring private methods in the interface part of the .m file?

I noticed from the template Apple gives with Core Data and UITableViewControllers that it puts the configureCell method in the interface section of the .m file.

@interface CustomTableViewController ()

- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;

@end

What is the benefit of doing this? Up until now I've always just wrote custom methods but not "declared" them anywhere else in the file like Apple does above. Should I be doing that?

Answers


This is old style and it isn't needed anymore. In older versions of the compiler, methods had to be in the proper order. In other words, a method could only call private methods that appeared before it in the .m file.

By adding the declaration of the private method in the class extension, the order problem went away. It also solved a problem if you had two methods that needed to call each other. Neither could be 1st.

But the modern compiler essentially does a two-pass compile now so there is no need for the private declarations anymore.


Need Your Help

Linq2Sql Testing

c# .net unit-testing linq-to-sql

I have test database and a production database. When developing I of course work against that test database then when deploying I have to semi-manually update the production database (by running a ...

How to create a form for a petition?

php javascript html css database

I need to create a form for a petition.