Is there any data binding mechanism available for iOS?

前端 未结 8 1228
执念已碎
执念已碎 2020-12-09 03:36

In .NET I just do something like DataForm.Source = Object and then magic happens. Platform routes data changes from ui fileds to object properties, does validation and so on

相关标签:
8条回答
  • 2020-12-09 04:03

    Yes, there is a data binding framework that integrates well into Interface Builder and requires only minimal code overhead (if at all).

    Take a look at https://github.com/mutech/aka-ios-beacon

    EDIT: You can for example bind a table view to a fetched results controller simply by setting the data source binding property of the table view in interface builder to:

    [ yourResultsController ] { defaultCellMapping: "YourCellId" }

    And the only thing you have to do is to define a property yourResultsController in your view controller.

    The wiki provides a rather complete documentation and a lot of example use cases.

    0 讨论(0)
  • 2020-12-09 04:04

    If you're using Swift, check out Bond framework: https://github.com/ReactiveKit/Bond

    Binding is as simple as:

    textField.reactive.text.bind(to: label.reactive.text)
    

    It plays well with functional:

    textField.reactive.text
      .map { "Hi " + $0 }
      .bind(to: label.reactive.text)
    

    And provides simple observations:

    textField.reactive.text
      .observeNext { text in
        print(text)
      }
    
    0 讨论(0)
提交回复
热议问题