You're looking for ReactiveCocoa - super awesome framework that does exactly what you asked for and more. Also a good way to implement MVVM - they have cool extensions that enable that ReactiveViewModel as well as extensions for AFNetworking
Databinding in iOS/OSX frameworks
-
01-07-2023 - |
Question
I wonder if there is any frameworks I'm not aware that I can use to achieve the concept of databinding, bind a NSObject derived class (the model) to a UIControl/NSControl derived component properties.
For example I have a class with a property name
and I need to bind it to a UITextView text
property so that when the model's name
property changes the UITextView text
property updates.
I guess that there would be something built on the Key-Value Observing concept.
I would like something that is working in both OSX and iOS or any other related frameworks for the platforms.
Thank you.
Solution
OTHER TIPS
Take a look at AKA Beacon (https://github.com/mutech/aka-ios-beacon). It's a binding framework that allows you to bind views to properties right from interface builder. The view controller (by default) serves as view model for bindings. You just have to add one line of code to the view controller to activate binding support and the framework takes care for all the rest.
Beacon supports most standard views (Label, TextField/View, Image, Slider, Stepper, Switch, TableView, etc.). It's relatively easy to write extension bindings for custom views.