2011-03-28 74 views
8

我正在开发我的第一个iOS/Cocoa Touch应用程序,并且为了处理用户设置,我需要为导航控制器构建几个表格视图。无论如何,我创建了一个自定义的UITableViewController,并将其推送到我的UINavigationController上。在以下两种方法中,我没有改变一个东西(除了返回数字),但是它们在XCode中发出了警告。是什么赋予了?UITableViewController:不完整的方法实现警告有什么用?

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
#warning Potentially incomplete method implementation. 
// Return the number of sections. 
return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
#warning Incomplete method implementation. 
// Return the number of rows in the section. 
return 3; 
} 

回答

20

#warning指令足够恰当地导致编译器发出警告。删除这两行,警告应该消失。

+0

有趣。为什么他们在那里呢?苹果公司指出你需要改变返回值吗? – Gregir 2011-03-28 03:05:58

+0

@Gregir:这可能正是它的目的。 – Anomie 2011-03-28 03:18:40

+0

感谢您的快速回答。无法相信我迄今为止在所有阅读中都错过了#warning指令的概念。 – Gregir 2011-03-28 03:20:54