我有一个表示UIPickerView行的数组:
var exerciseArray = ["Sitting","Walking","Bowling","Biking Slow","Biking Fast","Golf","SoftBall","BaseBall","Weight Training","Ice Skating","Tennis","Basketball","Jogging","Swimming","Soccer","Jump Rope"]
如何为var exerciseArray
中的每个不同行指定不同的数字值,以便稍后我可以访问这些指定的数字进行计算?
我是编程新手,所以请提供尽可能多的代码。谢谢!
答案 0 :(得分:0)
struct Model {
var name: String
var number: Int
}
var exersise : [Model] = []
var Position1 = Model(name: "Sitting", number: 100)
var Position2 = Model(name: "Walking", number: 130)
var Position3 = Model(name: "Bowling", number: 160)
var Position4 = Model(name: "Biking", number: 200)
var Position5 = Model(name: "Golf", number: 300)
exersise = [Position1,Position2,Position3,Position4,Position5]
println(exersise[0].name)
println(exersise[0].number)
for var index = 0; index < exersise.count; index++ {
println("Name = \(exersise[index].name) and has the number = \(exersise[index].number)")
}