【发布时间】:2014-04-21 16:00:05
【问题描述】:
假设我有一个符合协议的 Objective-C 类。在类中,我实现了协议中的一些方法。我应该在类扩展中声明这些方法还是应该避免它?
示例
// MyViewController.h
@interface MyViewController : UIViewController
<UITableViewDataSource>
@end
// MyViewController.m
@interface MyViewController ()
// Should I skip this?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
@end
@implementaion MyViewController
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// The implementaion goes here
}
@end
【问题讨论】:
标签: objective-c class methods protocols declaration