@interface RootViewController ()
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
@end
Why declare on .m Instead of declaring it on the .h itself?
Will it be easier to put one line (the one below) on the header file?
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
I have seen this in other codes Method. I’m still learning Objective-C, I want to know why this happens.
Thank you.
@interface RootViewController ()
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
@end
is a class extension (=anonymous category; the “normal” category has category names between (). Its purpose is to declare private methods (otherwise, if you try before implementing Call configureCell:atIndexPath: in the .m file, and you will receive a compiler warning).
You can read more about categories and class extensions in the developer documentation
I am using Xcode’s navigation-based application to create a new file, and I see that the .m file contains the following lines:
@interface RootViewController ()
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
@end
Why is it declared on .m but not on. H itself?
Will it be easier to put a line (the following line) in the header file?
- (void)configureCell: (UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
I have seen this method in other code. I am still learning Objective-C, I want to know why this is the case.
Thank you.
By not putting it into the public interface of the class, you are actually a private method (it won’t stop people outside your class if they really want to call it, But at least it will cause the compiler to warn).
@interface RootViewController ()
- (void)configureCell:(UITableViewCell *)cell atIndexPath:( NSIndexPath *)indexPath;
@end
is a class extension (=anonymous category; the “normal” category has category names between (). Its purpose is to declare private methods (otherwise, if If you try to call configureCell:atIndexPath: in the .m file before implementation, you will receive a compiler warning).
You can read more about categories and class extensions in the developer documentation
p>