Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Dec 24, 2015
1 parent c036874 commit b13f23f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Then
At a Glance
-----------

Initialize UILabel **then** setting its properties.
Initialize UILabel **then** set its properties.

```swift
let label = UILabel().then {
Expand All @@ -33,23 +33,29 @@ let label: UILabel = {
}()
```

#### Not prefer using `$0`?
You can use `then()` to all of `NSObject` subclasses.

Give it a name. (e.g. `this`)
```swift
let queue = NSOperationQueue().then {
$0.maxConcurrentOperationCount = 1
}
```

Want to use with your own classes? Just make extensions.

```swift
let label = UILabel().then { this in
this.textAlignment = .Center
this.textColor = .blackColor()
this.text = "Hello, World!"
extension MyClass: Then {}

let instance = MyClass().then {
$0.really = "awesome!"
}
```


Real World Example
------------------

Exmaple usage in an UIViewController subclass.
Here's an exmaple usage in an UIViewController subclass.

```swift
final class MyViewController: UIViewController {
Expand Down

0 comments on commit b13f23f

Please sign in to comment.