的人我怎麼可以把我的代碼:簡單的代碼迅疾reactiveswift
struct CarModel {
var model: String?
var make: String?
var kilowatts: Int?
var photoURL: String?
init(model: String, make: String, kilowatts: Int, photoURL: String) {
self.model = model
self.make = make
self.kilowatts = kilowatts
self.photoURL = photoURL
}
}
和:
class CarViewModel {
private var car: Car?
static let HPperKW = 1.34102209
var modelText: String? {
return car?.model
}
var makeText: String? {
return car?.make
}
var horsepowerText: String? {
guard let kilowatts = car?.kilowatts else { return nil }
let HP = Int(round(Double(kilowatts) * CarViewModel.HPperKW))
return "\(HP) HP"
}
var titleText: String? {
guard let make = car?.make, let model = car?.model else { return nil }
return "\(make) \(model)"
}
var photoURL: URL? {
guard let photoURL = car?.photoURL else { return nil }
return URL(string: photoURL)
}
init(_ car: Car) {
self.car = car
}
}
到ReactiveCocoa/ReactiveSwift。我讀了。有關Reactive的文檔,但我不明白我如何在我的代碼中實現Reactive API。 誰知道我需要怎麼做,請告訴我。 另外一個誰知道最後的版本ReactiveCocoa/ReactiveSwift的好樣本/例子/教程,請告訴我。