【发布时间】:2016-02-19 11:16:40
【问题描述】:
伙计们,我收到了这个错误
变量 courseTitle 从未改变
在尝试使用“dequeueReusableCellWithIdentifier”时。
这是我的代码:
import UIKit
class ViewController: UIViewController, UITableViewDataSource {
let devCourses = [("iOS App Dev with Swift Essential Training","Simon Allardice"),
("iOS 8 SDK New Features","Lee Brimelow"),
("Data Visualization with D3.js","Ray Villalobos"),
("Swift Essential Training","Simon Allardice"),
("Up and Running with AngularJS","Ray Villalobos"),
("MySQL Essential Training","Bill Weinman"),
("Building Adaptive Android Apps with Fragments","David Gassner"),
("Advanced Unity 3D Game Programming","Michael House"),
("Up and Running with Ubuntu Desktop Linux","Scott Simpson"),
("Up and Running with C","Dan Gookin")]
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return devCourses.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
var (courseTitle, courseAuthor) = devCourses[indexPath.row]
cell.textLabel?.text = courseTitle
return cell
}
有什么想法吗?
【问题讨论】:
-
另请阅读警告的第二部分,这就是 idea
-
它说:从未使用过变量“courseAuthor”;考虑用“_”替换或删除它
-
这是一个新警告,我的意思是您问题中提到的原始警告。无论如何,编译器总是试图给出合理的建议。