我写了这个循环。但是,我想知道是否可以不使用 name 属性而只引用对象的名称?
class Param {
var name = ""
var value = 0.0
var skip = -1
}
let depth = Param()
depth.name = "depth"
let tankPressure = Param()
tankPressure.name = "tankPressure"
let time = Param()
time.name = "time"
let tankCapacity = Param()
tankCapacity.name = "tankCapacity"
let litresPerMinute = Param()
litresPerMinute.name = "litresPerMinute"
let params = [depth, tankPressure, time, tankCapacity, litresPerMinute]
for param in params {
let outlet = "\(param.name)Outlet.text!"
print(outlet)
}