Skip to content
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

Migrate codebase to Swift 3.0 #345

Merged
merged 12 commits into from
Nov 25, 2016
Merged

Migrate codebase to Swift 3.0 #345

merged 12 commits into from
Nov 25, 2016

Conversation

cocojoe
Copy link
Member

@cocojoe cocojoe commented Nov 24, 2016

No description provided.

Changed router to class as can’t reference mutating structs in closure
Refactored Range<Int> to CountableClosedRange<Int>
Some ugly explicit bridging
Change func option(…) to withOptions(…) in Lock.Swift
Removed test code
didSet {
self.iconView?.tintColor = self.titleColor
self.button?.setTitleColor(self.titleColor, forState: .Normal)
self.button?.setTitleColor(self.titleColor, for: UIControlState())
Copy link
Member

Choose a reason for hiding this comment

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

Use []

guard case .Big = self.size else { return }
self.button?.setTitle(self.title, forState: .Normal)
guard case .big = self.size else { return }
self.button?.setTitle(self.title, for: UIControlState())
Copy link
Member

Choose a reason for hiding this comment

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

Use []


public init(size: Size) {
self.size = size
super.init(frame: CGRectZero)
super.init(frame: CGRect.zero)
Copy link
Member

Choose a reason for hiding this comment

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

just .zero will do

self.logger.error("Response was not NSHTTURLResponse")
return callback(nil)
}

let payload: String?
if let data = data {
payload = String(data: data, encoding: NSUTF8StringEncoding)
payload = String(data: data, encoding: String.Encoding.utf8)
Copy link
Member

Choose a reason for hiding this comment

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

just .utf8

}
}
}

private mutating func updateEmail(value: String?) -> ErrorType? {
self.user.email = value?.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
private mutating func updateEmail(_ value: String?) -> Error? {
Copy link
Member

Choose a reason for hiding this comment

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

it will be more swifter to use update(email: String?) -> Error?

let error = self.emailValidator.validate(value)
self.user.validEmail = error == nil
return error
}

private mutating func updateUsername(value: String?) -> ErrorType? {
self.user.username = value?.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
private mutating func updateUsername(_ value: String?) -> Error? {
Copy link
Member

Choose a reason for hiding this comment

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

it will be more swifter to use update(username: String?) -> Error?

let error = self.usernameValidator.validate(value)
self.user.validUsername = error == nil
return error
}

private mutating func updatePassword(value: String?) -> ErrorType? {
private mutating func updatePassword(_ value: String?) -> Error? {
Copy link
Member

Choose a reason for hiding this comment

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

it will be more swifter to use update(password: String?) -> Error?

self.user.password = value
let error = self.passwordValidator.validate(value)
self.user.validPassword = error == nil
return error
}

private func handleLoginResult(result: Auth0.Result<Credentials>, callback: DatabaseAuthenticatableError? -> ()) {
private func handleLoginResult(_ result: Auth0.Result<Credentials>, callback: (DatabaseAuthenticatableError?) -> ()) {
Copy link
Member

Choose a reason for hiding this comment

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

here just use handle(result: Auth0.Result<Credentials>, callback: (DatabaseAuthenticatableError?) -> (

Don’t suppress Lock returns
@hzalaz hzalaz added this to the 2.0.0-rc.1 milestone Nov 25, 2016
@hzalaz hzalaz changed the title Swift 3.0 Migrate codebase to Swift 3.0 Nov 25, 2016
@hzalaz hzalaz merged commit e0be786 into v2 Nov 25, 2016
@hzalaz hzalaz deleted the swift-3.0 branch January 10, 2017 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants