Skip to content

Update to Swift 3#40

Merged
zenangst merged 17 commits into
masterfrom
swift-3
Oct 13, 2016
Merged

Update to Swift 3#40
zenangst merged 17 commits into
masterfrom
swift-3

Conversation

@onmyway133
Copy link
Copy Markdown
Contributor

@onmyway133 onmyway133 commented Oct 3, 2016

  • Find this a bit strange NSWorkspace.shared().open(url) vs UIApplication.shared.openURL(url)

@mention-bot
Copy link
Copy Markdown

@onmyway133, thanks for your PR! By analyzing the history of the files in this pull request, we identified @vadymmarkov, @zenangst and @jessearmand to be potential reviewers.

}
}

extension MutableCollectionType where Index == Int {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have a hard time extending MutableCollection, so extend on Array for now

Comment thread Sources/Router.swift Outdated
public protocol ErrorRoutable {

func handle(routeError: ErrorType, from currentController: Controller)
func handle(_ routeError: Error, from currentController: Controller)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would leave routeError in function signature, or maybe just error.

Comment thread Sources/Compass.swift Outdated
}

static func parseAsURL(url: NSURL, payload: Any? = nil) -> Location? {
static func parseAsURL(_ url: URL, payload: Any? = nil) -> Location? {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe parseAsUrl?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that parseAsURL is actually dealing with url components, so I rename it to parseComponents

Comment thread Sources/Compass.swift Outdated

public static func navigate(urn: String, scheme: String = Compass.scheme) {
guard let url = NSURL(string: "\(scheme)\(urn)") else { return }
public static func navigate(_ urn: String, scheme: String = Compass.scheme) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe navigate(to urn

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense

Comment thread Sources/String+Extensions.swift Outdated

func replace(string: String, with withString: String) -> String {
return stringByReplacingOccurrencesOfString(string, withString: withString)
func replace(_ string: String, with withString: String) -> String {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need this method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's just a syntactic sugar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, but it makes less sense in Swift 3 I think.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree, lets get rid of the Sugar that are fixed by Apple in Swift 3.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@onmyway133 Would you mind to remove this functions an use replacingOccurrences(of: string, with: withString) instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure

Comment thread Sources/TypeAlias.swift Outdated

func openURL(URL: NSURL) {
NSWorkspace.sharedWorkspace().openURL(URL)
func openURL(_ url: URL) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think func open(url: URL) is better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Putting the _ seems to be the default everywhere tho. Which is a bit stupid, since, if everyone needs underscore, why don't we delete the underscore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@RamonGilabert I think the idea is to move the last part of the function's name to be an argument name, like in the example above (like in good old Objective C times) So we have to use _ as less as possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, sorry, I thought you suggested func openURL(url: URL).

Comment thread Sources/TypeAlias.swift Outdated

func openURL(URL: NSURL) {
UIApplication.sharedApplication().openURL(URL)
func openURL(_ url: Foundation.URL) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't need Foundation here.

@onmyway133
Copy link
Copy Markdown
Contributor Author

Fixed as you suggest @vadymmarkov 😉

Comment thread Sources/Compass.swift Outdated

public static func parse(url: NSURL, payload: Any? = nil) -> Location? {
let path = url.absoluteString.substringFromIndex(scheme.endIndex)
public static func parse(_ url: URL, payload: Any? = nil) -> Location? {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would leave it like public static func parse(url: NSURL, payload: Any? = nil). Thought? @onmyway133 @zenangst @RamonGilabert ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, remove _. I like labels :)

Comment thread Compass.podspec
s.source_files = 'Sources/**/*'
s.frameworks = 'Foundation'

s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks

@vadymmarkov
Copy link
Copy Markdown
Contributor

I've started a GitHub review here and now it's hard to read this PR tbh, it's not clear what is fixed and what is not 😞 But there are 2 comments waiting for your reply @onmyway133 😄

Comment thread Sources/TypeAlias.swift

#if os(OSX)
public typealias Controller = NSViewController
public typealias CurrentController = NSViewController
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We preserve Controller for another use case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had a conflict with Controller in Spots so I decided to change this one to no "kidnap" the name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zenangst oh ja, because we have struct Compass so the namespace is lost

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should try and fix that thing, now is probably a good idea to address it as we are already doing some breaking changes in the migration. (breaking as in having to adopt new Swift 3 syntax).

@zenangst zenangst merged commit d5833d6 into master Oct 13, 2016
@zenangst zenangst deleted the swift-3 branch October 13, 2016 10:31
@zenangst zenangst mentioned this pull request Oct 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants