6. CARTHAGE
PERFORMANCE - BUILD
xcodebuild -workspace MvvmSample2.xcworkspace -scheme
MvvmSample2 18.92s user 5.33s system 257% cpu 9.415 total
xcodebuild -project MvvmSample.xcodeproj -target
MvvmSample 0.49s user 0.10s system 105% cpu 0.559 total
TIME COMMAND
+
XCODEBUILD DEBUG
16. MVVM - 関連の定義付け易さ
‣ SwiftBond/Bond
Libraries for the Swiftbyyohei sugigami
http://sssslide.com/speakerdeck.com/susieyy/libraries-for-the-
swift
‣ <~は廃止された、bindって書くことになった
‣ KVOを綺麗に書ける感じ
textField.bnd_text.bindTo(viewModel.text)
class HomeViewModel {
var text = Observable<String?>(“")
}
http://sssslide.com/speakerdeck.com/susieyy/libraries-for-the-swift
17. MVVM - なにが便利?
SWIFTBONDで始めるMVVM
▸ https://github.com/SwiftBond/Bond
import UIKit
class HomeViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBOutlet weak var textField: UITextField!
let viewModel = HomeViewModel()
override func viewDidLoad() {
super.viewDidLoad()
textField.bnd_text.bindTo(viewModel.text)
label.bnd_text.bidirectionalBindTo(viewModel.text)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
class HomeViewModel {
var text = Observable<String?>("")
}
Bindされることで、
Modelの変更がViewに反映される。
Controllerに書くべき処理、
Modelでするべき処理が明確になる