篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Swift - 从另一个类调用一个方法相关的知识,希望对你有一定的参考价值。
class CarFactory {
var name = ""
var color = ""
var horsepower = 0
var automaticOption = false
func description() {
println("My \(name) is \(color) and has \(horsepower) horsepowers")
}
}
var myCar = CarFactory()
myFirstCar.name = "Mustang"
myCar.color = "Red"
myCar.horsepower = 200 myCar.automaticOption = true
myFirstCar.description() // $: "My Mustang is Red and has 200 horsepowers and is Automatic"
以上是关于swift Swift - 从另一个类调用一个方法的主要内容,如果未能解决你的问题,请参考以下文章