Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Swift 4.0 Support. #48

Merged
merged 2 commits into from
Nov 30, 2017
Merged

Swift 4.0 Support. #48

merged 2 commits into from
Nov 30, 2017

Conversation

DwayneCoussement
Copy link
Contributor

Upgraded all the things to Swift 4.0, not more than that.

Copy link
Member

@wojciechczerski wojciechczerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one small comment but apart from that the changes look very good. Thank you!

@@ -34,7 +34,7 @@ extension Monkey {
let alert = application.alerts.element(boundBy: i)
let buttons = alert.descendants(matching: .button)
XCTAssertNotEqual(buttons.count, 0, "No buttons in alert")
let index = UInt(self!.r.randomUInt32() % UInt32(buttons.count))
let index = Int(self!.r.randomUInt32() % UInt32(buttons.count))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use randomInt() method here? The code would look like this:

let index = self!.r.randomInt(lessThan: buttons.count)

Credits to @mohamede1945 who used this in his PR (#47).

@DwayneCoussement
Copy link
Contributor Author

You're welcome, it's fixed 👍

Copy link
Member

@wojciechczerski wojciechczerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@wojciechczerski
Copy link
Member

@DagAgren @DmitryBespalov I've checked the changes and I think they're fine. I we merge this branch and therefore migrate SwiftMonkey to Swift 4 we'll have to make sure that the next release of both Monkey and MonkeyPaws does not break any existing Swift 3 code.

To ensure this I would suggest to release both libraries with a major version bump. This will indicate the breaking changes and hopefully will prevent people from automatically updating SwiftMonkey to this source-incompatible version.

@@ -34,7 +34,7 @@ extension Monkey {
let alert = application.alerts.element(boundBy: i)
let buttons = alert.descendants(matching: .button)
XCTAssertNotEqual(buttons.count, 0, "No buttons in alert")
let index = UInt(self!.r.randomUInt32() % UInt32(buttons.count))
let index = self!.r.randomInt(lessThan: buttons.count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self! might crash, please move it out to guard let, like this:

addAction(interval: interval) { [weak self] in 
   guard let this = self else { return }

...
   let index = this.r.randomInt(...)

@@ -131,12 +131,12 @@ public class MonkeyPaws: NSObject, CALayerDelegate {
let originalMethod = class_getInstanceMethod(UIApplication.self, originalSelector)
let swizzledMethod = class_getInstanceMethod(UIApplication.self, swizzledSelector)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe guard let these two variables to avoid force unwrapping below

@wojciechczerski
Copy link
Member

I will merge this PR regardless of the suggested changes (consulted this with @DmitryBespalov). The mentioned code comments will be addressed in a separate PR.

@wojciechczerski wojciechczerski merged commit 3009465 into zalando:master Nov 30, 2017
This was referenced Nov 30, 2017
@DwayneCoussement DwayneCoussement deleted the feature/swift4.0 branch December 2, 2017 10:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants