I created two classes: StepsCell and WeightCell
import UIKit
class StepsCell {
let name = "Steps"
let count = 2000
}
import UIKit
class WeightCell {
let name = "Weight"
let kiloWeight = 90
}
In my VC, I am trying to create a cellArray array to hold objects.
import UIKit
class TableViewController: UIViewController {
var stepsCell = StepsCell()
var weightCell = WeightCell()
override func viewDidLoad() {
super.viewDidLoad()
var cellArray = [stepsCell, weightCell]
println(StepsCell().name)
println(stepsCell.name)
println(cellArray[0].name)
}
but when I index into an array:
println(cellArray[0].name)
I get zero .. Why? How can I create an array that “holds” these classes and which I can index to get various variables (and functions that will be added later). I thought it would be a very simple thing, but I can not find the answers to it. Any ideas?
source
share