-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NibReusable -> Reusable & NibLoadable #37
NibReusable -> Reusable & NibLoadable #37
Conversation
Thanks for this PR! Yup, that convenience |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just please:
- Update the README file accordingly (some documentation references that convenience protocol so if we get rid of it we should update the doc too)
- Add an entry in the CHANGELOG to mention the change and credit yourself
Thanks!
a5fcc90
to
f8c262b
Compare
I think that you should leave |
🤔 But then what's the point of this PR, if you don't mind me asking? |
If you will make a subclass of Or you just make a cell that is That is the point of PR. Lets create cell with theme. class MyCellWithTheme: UITableViewCell, Reusable {
var theme: Theme {
didSet {
setupTheme()
}
}
func setupTheme() {
// set bg color, fonts for default labels
}
} And this will not work in 3.0.0, but succeeds in my PR. // Subclass
class MyCustomCellWithTheme: MyCellWithTheme, NibLoadable {
@IBOutlet private var doStuffbutton: UIButton!
override func setupTheme() {
super.setTheme(theme)
// style for button
}
}
// Two protocols conforming
class MyAnotherCell: UITableViewCell, Reusable, NibLoadable {
} And it will not brake existing API, so there is no need to deprecate // And this will work too
class MyAnotherCell: UITableViewCell, NibReusable {
} |
Ok, I think I understand, but what surprises me then is that doing this change: - final func register<T: UICollectionViewCell>(cellType: T.Type) where T: NibReusable {
+ final func register<T: UICollectionViewCell>(cellType: T.Type) where T: Reusable & NibLoadable { Would change anything in your scenario… I mean, isn't it the same to conform to Or maybe if it is different — because |
Yep, it is different — because NibReusable is a separate protocol. 😱
But I think conformance to 2 protocols final func register<T: UICollectionViewCell>(cellType: T.Type) where T: Reusable & NibLoadable And in the case below you will see one protocol, but in fact there are two of them, so you should check both of them anyway, but it implicit. final func register<T: UICollectionViewCell>(cellType: T.Type) where T: NibReusable I'm agree that those protocols conform-and-go, but I prefer to check all frameworks used by me (especially small ones) for what is under the hood. |
Cool, let's go for this then! 👍
|
@@ -20,7 +20,7 @@ import Reusable | |||
* Which in fact is just a convenience protocol that combines | |||
* both `NibLoadable` + `Reusable` protocols. | |||
*/ | |||
final class MyXIBIndexSquaceCell: UICollectionViewCell, NibReusable { | |||
final class MyXIBIndexSquaceCell: UICollectionViewCell, Reusable, NibLoadable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we've decided to keep NibReusable
as a typealias, maybe keep the usage of NibReusable
in the example project here, especially since it's already explained in the comment that it's in fact just a convenience name combining both.
btw, you might also want to check the doc-comments throughout the code and sample project where we describe NibReusable
as "just a convenience protocol that combines both NibLoadable
+ Reusable
protocols" and change it to say it's a "convenience typealias combining NibLoadable & Reusable
" instead.
## UNRELEASED | ||
|
||
* Removed strict `NibReusable` protocol conforming in `register` functions. | ||
You can now make `Reusable` cell, and `NibLoadable` subclass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add 2 spaces after your full-stop here (see other entries for inspiration).
Ending a line with two spaces in Markdown allows to go to the next line in the same paragraph (like a <br>
) in the rendered document.
The typical formatting I use in the CHANGELOG is this, where •
represent a space:
* Change description.••
[@your_github_handle](link_to_your_gh_profile)
[#PR_Num](link_to_this_pr)
@@ -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 if they use a `XIB` file for their content (this will use `registerNib(…)` 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the NibReusable
typealias
Updated README.md & CHANGELOG.md.
2a22c19
to
416d505
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it kinda nice to add the information/aka you added before, like Use the NibReusable typealias (equivalent to Reusable & NibLoadable) if …
🤔 That's the 4th time I relaunch the Travis-CI build because each time it errors (it doesn't launch the job and fail, no, it just errors without even launching the build). I have no idea if that's linked to the shortage that Travis-CI is currently experiencing with OSX jobs or not, so if we should change something to make it build again or not, I'm a bit confused… (same problem with #38) |
Ok, still don't know why the Travis job keeps erroring, and I have no idea how to investigate further… so merging anyway after testing it locally. |
Hi.
There is no need in strict
NibReusable
protocol conforming inregister
functions. You can use protocol composition type.