作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
' with an index of type ' Int'-6ren"> ' with an index of type ' Int'-我想为我的家庭作业准备一个基本的数字选择器计时器,但我无法解决这个问题。 var timer = Timer() var counter = 0 //let number = ["1"-6ren">
我想为我的家庭作业准备一个基本的数字选择器计时器,但我无法解决这个问题。
var timer = Timer()
var counter = 0
//let number = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"]
let number = 1 ... 60
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return number[row]
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return number.count
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
label.text = number[row]
}
但它给出了这个错误。
Cannot subscript a value of type 'ClosedRange' with an index of type 'Int'
最佳答案
您正在创建一个数组,因此需要用方括号括住该范围。
let numbers = [1...60]
关于ios - 如何快速修复 "Cannot subscript a value of type ' ClosedRange<Int >' with an index of type ' Int',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56609138/
我是一名优秀的程序员,十分优秀!