Two-way data binding framework for iOS. Only one API to learn.

Overview

BindKit

A simple to use two-way data binding framework for iOS. Only one API to learn.

Supports Objective-C, Swift 5, Xcode 10.2, iOS 8 and above.

Ships as a cocoapod or static library ready for you to link into your app (or you can include the source directly into your project). The static library is built as a 'fat' library and includes the following architectures: i386, x86_64, armv7s, armv7, arm64 and bitcode.

Looking for an older version?

Tagged version 1.0.0 supports Objective-C, Swift 3 and 4, Xcode 8, 9 and 10, iOS 8 and above.

Currently supported views

The following views are supported directly by BindKit:

View class View properties
UIBarButtonItem enabled
UIButton enabled, hidden
UIDatePicker date, enabled, hidden
UIImageView image, hidden
UILabel text, attributedText, hidden
UIPageControl currentPage, numberOfPages, enabled, hidden
UISegmentedControl selectedSegmentIndex, enabled, hidden
UISlider value, enabled, hidden
UIStepper value, enabled, hidden
UISwitch on, enabled, hidden
UITextFieldText text, attributedText, enabled, hidden
UITextView text, attributedText, editable, hidden

Don't see the property or class you're interested in? Submit a pull request with your changes to add the property or class, or use the Vendor API to add custom functionality in your own app. See MySearchBar.swift in BindingExample for an example of custom functionality using the Vendor API.

Binding

Data binding is two-way - any changes to your models properties are automatically applied to your views properties and vice versa.

There is only one API to learn:

Objective-C

[model bindObjectSel: @selector(addressStr) toView: addressTextField viewKey: UITextFieldText];

Swift

model.bindObjectKey(#keyPath(model.addressStr), toView: addressTextField, viewKey: UITextFieldText)

Just a few simple rules

The following rules apply when using BindKit with Swift:

  1. Your model object must inherit from NSObject.
  2. Your models properties that participate in binding need to be marked @objc dynamic.

See under the hood for implementation details.

Example

Swift

class LogonModel: NSObject {
	
	@objc dynamic var username: String!
	@objc dynamic var password: String!
	@objc dynamic var logonEnabled: Boolean
	
	override func boundPropertiesDidUpdate() {
		logonEnabled = validate()
	}

	func validate() -> Boolean
		guard username!.trimmingCharacters(in: CharacterSet.whitespaces).count > 0 else { return false }
		guard password!.trimmingCharacters(in: CharacterSet.whitespaces).count > 0 else { return false }
		return true
	}
}

class LogonController: UITableViewController {

	@IBOutlet weak var usernameTextField: UITextField!
	@IBOutlet weak var passwordTextField: UITextField!
	@IBOutlet weak var logonButton: UIButton!

	var model = LogonModel()

	override func viewDidLoad() {
		model.bindKey(#keyPath(model.username), view: usernameTextField, viewKey: UITextFieldText)
		model.bindKey(#keyPath(model.password), view: passwordTextField, viewKey: UITextFieldText)
		model.bindKey(#keyPath(model.logonEnabled), view: logonButton, viewKey: UIButtonEnabled)
	}

}

Adding BindKit to your app (Manual integration)

  • Link libBindKit.a into your app
  • Configure Header Search Paths to allow Xcode to find BindKit.h and BindKitVendor.h
  • Add -ObjC and -all_load to Other Linker Flags

Adding BindKit to your app (Cocoapods integration)

  • If you have not already created a Podfile for your application, create one now: pod init
  • Add the following into your Podfile: pod 'BindKit'
  • Save the file and run: pod install

Building

Whilst the libBindKit.a static library is prebuilt and included in the repository, if you need to rebuild then execute the following command:

./buildlibrary.sh

The resulting static library and header files will be placed into the release directory.

The build script currently assumes Xcode 10.2/SDK12.2. If you are using a different Xcode build chain, tweak the IOSSDK_VER variable in the build script as appropriate.

Under the hood

Model

Model properties that participate in binding are monitored for changes using Key-Value-Observing (KVO). For this reason model objects must inherit from NSObject, and if using Swift, properties must be marked with @objc dynamic.

View

Views that participate in binding are dynamically subclassed at runtime. There is one dynamic subclass implemented for each supported view. Depending on the view, different methods for monitoring changes are required: target-action, delegation or notifications.

View not supported? Submit a pull request with your changes to add the property or class, or use the Vendor API to add custom functionality in your own app.

You might also like...
Unidirectional Data Flow in Swift - Inspired by Redux
Unidirectional Data Flow in Swift - Inspired by Redux

ReSwift Supported Swift Versions: Swift 4.2, 5.x For Swift 3.2 or 4.0 Support use Release 5.0.0 or earlier. For Swift 2.2 Support use Release 2.0.0 or

A super simple library for state management with unidirectional data flow.
A super simple library for state management with unidirectional data flow.

OneWay 🚧 OneWay is still experimental. As such, expect things to break and change in the coming months. OneWay is a super simple library for state ma

RxSwift bindings for Permissions API in iOS.

RxPermission RxSwift bindings for Permission API that helps you with Permissions in iOS. Installation RxPermission is available through CocoaPods. I c

A configurable api client based on Alamofire4 and RxSwift4 for iOS

SimpleApiClient A configurable api client based on Alamofire4 and RxSwift4 for iOS Requirements iOS 8.0+ Swift 4 Table of Contents Basic Usage Unwrap

RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.
RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.

Written in Swift 5 RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with

Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.

Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift. ⚠️ Looking for the Objective-C API? 🎉 Migrating from RAC 4.x? 🚄 Release Road

Aftermath is a stateless message-driven micro-framework in Swift
Aftermath is a stateless message-driven micro-framework in Swift

Aftermath is a stateless message-driven micro-framework in Swift, which is based on the concept of the unidirectional data flow architecture.

An observables framework for Swift
An observables framework for Swift

🐌 snail A lightweight observables framework, also available in Kotlin Installation Carthage You can install Carthage with Homebrew using the followin

A Swift framework for reactive programming.

CwlSignal An implementation of reactive programming. For details, see the article on Cocoa with Love, CwlSignal, a library for reactive programming. N

Releases(1.0.1)
Owner
Electric Bolt
Tools for developers and testers
Electric Bolt
XTerminalUI - xterm.js binding to Apple user interface frameworks

XTerminalUI xterm.js binding to AppleUI with WebKit. Preview Usage We recommend

Lakr Aream 16 Jul 15, 2022
CMPSC475 Final Project, ArboretumID Application allows users to explore the Penn State Arboretum, identify plants and learn about the exhibits!

ArboretumID: CMPSC475 Final Project Taylan Unal (@taylanu) About ArboretumID ArboretumIdentifier (ArboretumID) is an app that enhances the Penn State

Taylan 1 Nov 27, 2021
RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.

About Architecture concerns RxReduce Installation The key principles How to use RxReduce Tools and dependencies Travis CI Frameworks Platform Licence

RxSwift Community 125 Jan 29, 2022
This Repository holds learning data on Combine Framework

Combine Framework List of Topics Welcome, every section in this repo contains a collection of exercises demonstrating combine's utilization as well as

Julio Ismael Robles 2 Mar 17, 2022
The easiest way to observe values in Swift.

Observable is the easiest way to observe values in Swift. How to Create an Observable and MutableObservable Using MutableObservable you can create and

Robert-Hein Hooijmans 368 Nov 9, 2022
UIKitPreviews - A simple way to see your UIKit ViewController changes live and on-demand

SwiftUI preview provider for UIKit A simple way to see your UIKit ViewController

Emad Beyrami 8 Jan 8, 2023
Core Data with ReactiveCocoa

ReactiveCoreData ReactiveCoreData (RCD) is an attempt to bring Core Data into the ReactiveCocoa (RAC) world. Currently has several files with the sour

Jacob Gorban 258 Aug 6, 2022
Unidirectional Data Flow in Swift - Inspired by Redux

ReSwift Supported Swift Versions: Swift 4.2, 5.x For Swift 3.2 or 4.0 Support use Release 5.0.0 or earlier. For Swift 2.2 Support use Release 2.0.0 or

null 7.3k Dec 25, 2022
RxSwift extensions for Core Data

RxCoreData Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Xcode 9.0 Swift 4.0

RxSwift Community 164 Oct 14, 2022
🔄 Unidirectional data flow in Swift.

Reactor Reactor is a framework for making more reactive applications inspired by Elm, Redux, and recent work on ReSwift. It's small and simple (just o

Reactor 175 Jul 9, 2022