-
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
Renamed storyboard property to unified sceneStoryboard #33
Conversation
Hey, thanks for the PR! I don't understand though why you would do |
So for me the only change to do is on line 45 where indeed there's this extra |
@@ -42,8 +42,8 @@ public extension StoryboardSceneBased where Self: UIViewController { | |||
- returns: instance of the conforming ViewController | |||
*/ | |||
static func instantiate() -> Self { | |||
let storyboard = Self().storyboard | |||
guard let vc = storyboard?.instantiateViewController(withIdentifier: self.sceneIdentifier) as? Self else { |
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.
(To me those two lines after the only one needing to be changed, to fix the bug you mention)
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.
Exactly. Removing Extra ()
solving problem. However compiler is raising an issue when you trying to call self.storyboard from instantiate() function (again it's pointing to UIViewController.storyboard instead to StoryboardBased.storyboard).
Its possible to add default implementation for StoryboardSceneBased like this:
public extension StoryboardSceneBased {
static var sceneIdentifier: String {
return String(describing: self)
}
static var storyboard: UIStoryboard {
return UIStoryboard(name: "foo", bundle: nil)
}
}
to switch Swift compiler to use dedicated static method, but it's dumb workaround.
After fail of all my tries with 'self' combinations to pass compilation I proposed to rename property name.
This issue also affects example attached to library (instantiate Details View Controller after tapping Details button in InfoCell 0 or 1)
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.
Ah, right. Then shouldn't we use Self.storyboard
(And not self.storyboard
) in instantiate()
then?
I agree that renaming the property to avoid confusion would be a good idea but as it's also a breaking change (and thus requires to bump the major version) I'm trying to avoid it just to solve a bug 😉
What do you say we split this PR in two?
We could also keep the |
@jakubgert Nice catch! But we could avoid such problem if we would have unit tests. Could you add them for your code? |
@AliSoftware as I mentioned before,
This will not work because of Swift will not allow to to this without default protocol implementation.
That sounds good. But with UT @Grubas7 |
@jakubgert I'm not sure I understand why a PR just to fix the bug wouldn't work? |
Exactly, that protocols works, but in this particular case after change from: Self().storyboard (which was wrong) to Self.storyboard (where expected is to call static var storyboard: UIStoryboard getter) I have Swift Compiler error: After rename static var storyboard: UIStoryboard to any other everything works fine. I hope this is more clear. I should mention about it at the beginning. |
Ah, I see it now, thx for the detailed explanation. We should file a bug report at bugs.swift.org about that btw (the fact that it only see the In the meantime, I managed to make it compile by adding some hints to the compiler, using this: I'm sorry to insist on doing it in two parts, but semantic versioning and API change means that a lot of people won't probably upgrade to the future Reusable 4.0.0 just yet and won't have the bug fix very soon if we only fix it in 4.0.0, so… 😉 |
This is working: Regarding bug on Swift, I'm working on small example which I want to attach with description and submit. It will be ready soon. |
Would love to! Thanks again 👍 |
@jakubgert Any news on splitting this PR so that we can at least merge the bug-fix as a minor version bump? |
Apologies for delay, I was really buy last week. |
Cool. Waiting for you to add a CHANGELOG entry in #38 so I can merge it quickly thn (even if Travis is having issues recently and the PR validation by Travis might take some time). I'll keep this #33 open for now, as once #38 is merged we could just rebase this PR #33 on top of it to keep the renaming (but only merge it as a new, breaking major version after the release of the minor version including #38) |
@jakubgert Any chance you could rebase this PR on top of master so we can have this renaming done and publish a new major release? Thx! |
Merged via 7d5216d |
For reference: https://bugs.swift.org/browse/SR-4615 |
Current implementation for instantiating VC from storyboard is not working correctly.
Self().storyboard from StoryboardSceneBased.swift is creating new instance of VC and then reading "storyboard" property. However value of read property is not from StoryboardBased.storyboard (which is static) but from UIViewController.storyboard (which is optional).
I'm proposing small change (but it's breaking API change) by renaming property from 'storyboard' to 'sceneStoryboard' for avoid conflicts and make code working correctly.