Skip to content

Commit

Permalink
Update for Swift 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuch committed Mar 22, 2016
1 parent 9460aee commit 7d6789e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class ViewController: UIViewController, StatefulViewController {
super.viewDidLoad()

// Setup refresh control
refreshControl.addTarget(self, action: Selector("refresh"), forControlEvents: .ValueChanged)
refreshControl.addTarget(self, action: #selector(refresh), forControlEvents: .ValueChanged)
tableView.addSubview(refreshControl)

// Setup placeholder views
loadingView = LoadingView(frame: view.frame)
emptyView = EmptyView(frame: view.frame)
let failureView = ErrorView(frame: view.frame)
failureView.tapGestureRecognizer.addTarget(self, action: Selector("refresh"))
failureView.tapGestureRecognizer.addTarget(self, action: #selector(refresh))
errorView = failureView
}

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/aschuch/StatefulViewController.svg)](https://travis-ci.org/aschuch/StatefulViewController)
![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)
![Swift 2](https://img.shields.io/badge/Swift-2-orange.svg)
![Swift 2.2](https://img.shields.io/badge/Swift-2.2-orange.svg)

A protocol to enable `UIViewController`s or `UIView`s to present placeholder views based on content, loading, error or empty states.

Expand All @@ -26,18 +26,18 @@ As trivial as this flow may sound, there are a lot of cases that result in a rat
First, make sure your view controller adopts to the `StatefulViewController` protocol.

```swift
```swift
class MyViewController: UIViewController, StatefulViewController {
// ...
}
```
```

Then, configure the `loadingView`, `emptyView` and `errorView` properties (provided by the `StatefulViewController` protocol) in `viewDidLoad`.

```swift
override func viewDidLoad() {
super.viewDidLoad()

// Setup placeholder views
loadingView = // UIView
emptyView = // UIView
Expand All @@ -50,7 +50,7 @@ In addition, call the `setupInitialViewState()` method in `viewWillAppear:` in o
```swift
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

setupInitialViewState()
}
```
Expand All @@ -60,7 +60,7 @@ After that, simply tell the view controller whenever content is loading and `Sta
```swift
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

loadDeliciousWines()
}

Expand Down Expand Up @@ -180,4 +180,4 @@ xctool -scheme StatefulViewControllerTests -sdk iphonesimulator test
Feel free to get in touch.

* Website: <http://schuch.me>
* Twitter: [@schuchalexander](http://twitter.com/schuchalexander)
* Twitter: [@schuchalexander](http://twitter.com/schuchalexander)

0 comments on commit 7d6789e

Please sign in to comment.