在下面的函数调用.didSelectRating
什么是self
参数(?)表示?这究竟是什么?函数调用中的自变量是什么意思?
我在几次之前就已经看过这个,不知道如何了解这个语法,因为我不知道要查找什么。我明白第二个参数中的rating
单词是参数名称,但我不明白逗号前面的第一个单词是如何封装名称和参数的。
这是什么叫,它在做什么? self
是这里唯一使用的词还是可以在这里使用的其他东西?
protocol RatingPickerDelegate {
func preferredRatingSymbol(picker: RatingPicker) -> UIImage?
func didSelectRating(picker: RatingPicker, rating: Int)
func didCancel(picker: RatingPicker)
}
func selectRating(selectedRating: Int) {
delegate?.didSelectRating(self, rating: selectedRating)
// Other logic related to selecting a rating
}
参数标签的要求从Swift 2更改为Swift 3.我猜这个代码是Swift 2;有关更多信息,请参阅https://github.com/apple/swift-evolution/blob/master/proposals/0046-first-label.md。 – sbooth