这一行来自我正在关注的教程,看看第二个参数。来自另一种语言,'cellForRowAtIndexPath'是意想不到的。这个变量的目的是什么(根据Swift语言,而不是iOS框架)&这个“额外变量”的概念叫什么,所以我可以做更多的个人研究?这个Swift函数声明中的额外变量是什么
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
这一行来自我正在关注的教程,看看第二个参数。来自另一种语言,'cellForRowAtIndexPath'是意想不到的。这个变量的目的是什么(根据Swift语言,而不是iOS框架)&这个“额外变量”的概念叫什么,所以我可以做更多的个人研究?这个Swift函数声明中的额外变量是什么
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
是,如果你是从Java或C#来它可以是奇数,我想基本上都是从不同的Objective-C的:) 在斯威夫特任何其他语言有外部和内部参数的概念。在你的例子中,cellForRowAtIndexPath
是方法调用者'可见'的外部名字,'indexPath'是在方法实现中使用的内部或本地名称。调用它时
的cellForRowAtIndexPath是你从功能外看到的名称,所以:
请看下面的代码:
func someFunction(externalParameterName localParameterName: Int) {
// function body goes here, and can use localParameterName
// to refer to the argument value for that parameter
}
从indexPath是函数内的名称,通常是较短的一个。
NSIndex是