Reputation: 323
I'm trying my first project using reactive cocoa 4. In ViewModel I have
var title = MutableProperty<String>("")
and in ViewController
is binding
self.articleDetailView.titleLabel.rac_text <~ self.articleViewModel.title
I'm using for binding UIKit
extension from Colin Eberhardt (https://github.com/ColinEberhardt/ReactiveTwitterSearch/blob/master/ReactiveTwitterSearch/Util/UIKitExtensions.swift). It works nice for UILabel
etc.
My app using UIWebView
so I need to bind UIWebView
. I'm not sure how to do that. Currently in my non reactive code, I'm using method loadHTMLString
for loading content to my webView but I have no idea how to bind webView
with ViewModel.
Do anybody know how to bind UIWebView
?
Upvotes: 0
Views: 390
Reputation: 323
I have found answer on github. User "avalanched" (https://github.com/avalanched) send me this example:
You can bind a MutableProperty to loadHTMLString
if you have this in the ViewModel
var url : MutableProperty<NSURL>
you can bind it as such:
url.producer.map { NSURLRequest($0) }.startWithNext(webview.loadRequest)
Hope it helps somebody.
Upvotes: 0