2011-03-28 70 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