xcode UITableViewController:不完整的方法实现警告是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5454142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:40:23  来源:igfitidea点击:

UITableViewController: what's with the incomplete method implementation warnings?

xcodewarningsuitableview

提问by Gregir

I'm working on my first iOS/Cocoa Touch app, and to handle user settings, I need to build a few table views for a navigation controller. At any rate, I created a custom UITableViewController, and pushed it on my UINavigationController. I didn't change a thing (except the return numbers) in the following two methods, but they kick out warnings in XCode. What gives?

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

- (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;
}

回答by Anomie

The #warningdirective, appropriately enough, causes the compiler to emit a warning. Delete those two lines and the warnings should go away.

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