0

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後で計算のためにこれらの割り当てられた数値にアクセスできるように、異なる行のそれぞれに異なる数値を割り当てるにはどうすればよいですか?

私はプログラミングが初めてなので、できるだけ多くのコードを提供してください。ありがとうございました!

4

1 に答える 1

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)")  
}
于 2014-12-20T12:44:10.487 に答える