Skip to content

Commit

Permalink
Changed docs for NibReusable typealias.
Browse files Browse the repository at this point in the history
Updated README.md & CHANGELOG.md.
  • Loading branch information
nekrich committed Nov 29, 2016
1 parent 378aeab commit 2a22c19
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## UNRELEASED

* Removed strict `NibReusable` protocol conforming in `register` functions.
You can now make `Reusable` cell, and `NibLoadable` subclass.
[@nekrich](https://github.com/nekrich)
* Removed strict `NibReusable` protocol conforming in `register` functions.
You can now make `Reusable` cell, and `NibLoadable` subclass.
[@nekrich](https://github.com/nekrich)
[#37](https://github.com/AliSoftware/Reusable/pull/37)

## 3.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import Reusable
* and it uses the CollectionView recycling mechanism) => it is `Reusable`
*
* That's why it's annotated with the `NibOwnerLoadable` protocol,
* Which in fact is just a convenience protocol that combines
* both `NibLoadable` + `Reusable` protocols.
* Which in fact is just a convenience typealias that combines
* `NibLoadable` & `Reusable` protocols.
*/
final class CollectionHeaderView: UICollectionReusableView, NibReusable {
@IBOutlet private weak var titleLabel: UILabel! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import UIKit
import Reusable

/**
* This one can be either NibReusable or just Reusable it doesn't really matter,
* as we will never have to explicitly call collectionView.register(…) to register it:
* This one can be either `NibReusable` or just `Reusable` it doesn't really matter,
* as we will never have to explicitly call `collectionView.register(…)` to register it:
* The `Main.storyboard` already auto-registers its cells without the need for additional code
*
* The only difference in marking a view `NibReusable` vs. `Reusable` is the way
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import Reusable
* and it uses the CollectionView recycling mechanism) => it is `Reusable`
*
* That's why it's annotated with the `NibOwnerLoadable` protocol,
* Which in fact is just a convenience protocol that combines
* both `NibLoadable` + `Reusable` protocols.
* Which in fact is just a typealias that combines
* `NibLoadable` & `Reusable` protocols.
*/
final class MyXIBIndexSquaceCell: UICollectionViewCell, Reusable, NibLoadable {
final class MyXIBIndexSquaceCell: UICollectionViewCell, NibReusable {
@IBOutlet private weak var sectionLabel: UILabel!
@IBOutlet private weak var rowLabel: UILabel!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import UIKit
import Reusable

// This one can be either NibReusable or just Reusable it doesn't matter actually
// As we will never have to explicitly call tableView.register(…) to register it:
// This one can be either `NibReusable` or just `Reusable` it doesn't matter actually
// As we will never have to explicitly call `tableView.register(…)` to register it:
// The Main.storyboard already auto-registers its cells without the need for additional code

final class MyStoryBoardIndexPathCell: UITableViewCell, Reusable {
Expand Down
6 changes: 3 additions & 3 deletions Example/ReusableDemo/TableViewCells/MyXIBInfoCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import Reusable
* It is also reusable and has a `reuseIdentifier` (as it's a TableViewCell
* and it uses the TableView recycling mechanism) => it is `Reusable`
*
* That's why it's annotated with the `NibReusable` protocol,
* Which in fact is just a convenience protocol that combines
* both `NibLoadable` + `Reusable` protocols.
* That's why it's annotated with the `NibReusable` typealias,
* Which in fact is just a convenience typealias that combines
* `NibLoadable` & `Reusable` protocols.
*/
final class MyXIBInfoCell: UITableViewCell, NibReusable {

Expand Down
6 changes: 3 additions & 3 deletions Example/ReusableDemo/TableViewCells/MyXIBTextCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import Reusable
* It is also reusable and has a `reuseIdentifier` (as it's a TableViewCell
* and it uses the TableView recycling mechanism) => it is `Reusable`
*
* That's why it's annotated with the `NibReusable` protocol,
* Which in fact is just a convenience protocol that combines
* both `NibLoadable` + `Reusable` protocols.
* That's why it's annotated with the `NibReusable` typealias,
* Which in fact is just a convenience typealias that combines
* `NibLoadable` & `Reusable` protocols.
*/
final class MyXIBTextCell: UITableViewCell, NibReusable {

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This concept, called a [Mixin](http://alisoftware.github.io/swift/protocol/2015/
## 1. Declare your cells to conform to `Reusable` or `NibReusable`

* Use the `Reusable` protocol if they don't depend on a NIB (this will use `registerClass(…)` to register the cell)
* Use the `NibReusable` protocol (aka combination of `Reusable` & `NibLoadable` protocols) if they use a `XIB` file for their content (this will use `registerNib(…)` to register the cell)
* Use the `NibReusable` typealias if they use a `XIB` file for their content (this will use `registerNib(…)` to register the cell)

```swift
final class CustomCell: UITableViewCell, Reusable { /* And that's it! */ }
Expand Down Expand Up @@ -394,7 +394,7 @@ In some cases you can avoid making your classes `final`, but in general it's a g

## Customize reuseIdentifier, nib, etc for non-conventional uses

The protocols in this pod, like `Reusable`, `NibLoadable`, `NibReusable`, `NibOwnerLoadable`, `StoryboardBased`… are what is usually called [Mixins](http://alisoftware.github.io/swift/protocol/2015/11/08/mixins-over-inheritance/), which basically is a Swift protocol with a default implementation provided for all of its methods.
The protocols in this pod, like `Reusable`, `NibLoadable`, `NibOwnerLoadable`, `StoryboardBased`, `NibReusable`… are what is usually called [Mixins](http://alisoftware.github.io/swift/protocol/2015/11/08/mixins-over-inheritance/), which basically is a Swift protocol with a default implementation provided for all of its methods.

The main benefit is that **you don't need to add any code**: just conform to `Reusable`, `NibOwnerLoadable` or any of those protocol and you're ready to go with no additional code to write.

Expand Down
2 changes: 1 addition & 1 deletion Sources/View/Reusable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public protocol Reusable: class {
}

/// Make your `UITableViewCell` and `UICollectionViewCell` subclasses
/// conform to this protocol when they *are* NIB-based
/// conform to this typealias when they *are* NIB-based
/// to be able to dequeue them in a type-safe manner
public typealias NibReusable = Reusable & NibLoadable

Expand Down

0 comments on commit 2a22c19

Please sign in to comment.