I am trying to observe a property in my ViewModel and then update the label with its value using ReactiveCocoa, but it is not updating.
Here is what I got:
ViewModel
var amount: NSDecimalNumber
ViewController
RAC(self.amountLabel, "text") <~ RACObserve(self.viewModel, "amount").map({ (value) -> AnyObject! in let numberFormatter = NSNumberFormatter() numberFormatter.numberStyle = .CurrencyStyle return numberFormatter.stringFromNumber(value as NSDecimalNumber) })
I checked and ViewModel correctly updates the "amount" property. Is there something I'm missing here?
I also tried this for testing:
RACObserve(self.viewModel, "amount").subscribeNext { (value) -> Void in println(value) }
Does not work.
I use ReactiveCocoa 2.4.7 because my application supports iOS 7. Are there any incompatibilities between macro replacements in Swift [1,2] and this version?
[1] - https://github.com/ashfurrow/Swift-RAC-Macros
[2] - http://blog.scottlogic.com/2014/07/24/mvvm-reactivecocoa-swift.html
ios reactive-cocoa
dccarmo
source share