https://github.com/aryaxt/binder
https://github.com/aryaxt/binder
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/aryaxt/binder
- Owner: aryaxt
- License: other
- Created: 2016-05-01T22:41:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-02T15:45:33.000Z (about 10 years ago)
- Last Synced: 2024-12-29T23:22:17.810Z (over 1 year ago)
- Language: Swift
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License.txt
Awesome Lists containing this project
README
# Binder
[](https://api.travis-ci.org/aryaxt/Binder)
[](http://cocoadocs.org/docsets/Binder)
A simple UI Binder for swift
*** Still in development, DO NOT USE ***
#### UIControl
Bind to any existing UIControlEvents
```swift
anyUiControl.bindControlEvent(.AllEvents) { print("Any Event") }
```
#### UIButton
```swift
button.bindTap { print("tap on button") }
```
#### UITextField
```swift
textField.bindTextChange { print("text value: \($0)") }
```
#### UISegmentedControl
```swift
segmentedControl.bindValueChange { print("selected index \($0)") }
```
#### UITableView
Populate a table, this will use the class name as the cell identifier
```swift
tableview
.bindNumberOfRowsForSection { _ in self.tableData.count }
.bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }
```
Provide custom identifier for the cells
```swift
tableview
.bindNumberOfRowsForSection { _ in self.tableData.count }
.bindCellIdentifier { _ in "AwesomeCellNumber2" }
.bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }
```
Customize number of section
```swift
tableview
.bindNumberOfSections { return 2 }
.bindNumberOfRowsForSection { _ in self.tableData.count }
.bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }
```
Selection & Deselection
```swift
tableview
.bindNumberOfRowsForSection { _ in self.tableData.count }
.bindCell(AwesomeCell.self) { indexPath, cell in cell.configure(self.tableData[indexPath.row]) }
.bindSelection { indexPath in print("selected row: \(self.tableData[indexPath.row]))") }
.bindDeselection { indexPath in print("deselected row: \(self.tableData[indexPath.row]))") }
```