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

@discardableResult for becomeFirstResponder() and resignFirstResponder() #98

Merged
merged 3 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Master(unreleased)
-----------------


* Added `@discardableResult` to `becomeFirstResponder` and `resignFirstResponder`. This silences Xcode warnings about unused results of those functions and brings the implementation closer to the iOS API.

v2.0
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ShowcaseExampleViewController: UIViewController, UITextFieldDelegate {

self.setupThemeColors()

_ = self.departureCityField.becomeFirstResponder()
self.departureCityField.becomeFirstResponder()
}

// MARK: - Creating the form elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SettingTextsViewController: UIViewController {
}

@IBAction func resignTextField() {
_ = self.textField?.resignFirstResponder()
self.textField?.resignFirstResponder()
}

@IBAction func selectedTitleChanged(_ segmentedControl:UISegmentedControl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CustomizingColorsViewController: UIViewController {
}

@IBAction func resignTextField() {
_ = self.textField?.resignFirstResponder()
self.textField?.resignFirstResponder()
}

@IBAction func titleColorChanged(_ segmentedControl:UISegmentedControl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class SubclassingViewController: UIViewController {
}

@IBAction func resignTextField() {
_ = self.textField?.resignFirstResponder()
self.textField?.resignFirstResponder()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CustomLayoutViewController: UIViewController {
}

@IBAction func resignTextField() {
_ = self.textField?.resignFirstResponder()
self.textField?.resignFirstResponder()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DelegateMethodsViewController: UIViewController, UITextFieldDelegate {
}

@IBAction func resignTextField() {
_ = self.textField?.resignFirstResponder()
self.textField?.resignFirstResponder()
}

func log(text:String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase {
floatingLabelTextField.errorMessage = "Error"

// when
_ = floatingLabelTextField.becomeFirstResponder()
floatingLabelTextField.becomeFirstResponder()

// then
XCTAssertEqual(floatingLabelTextField.errorMessage, "Error")
Expand Down Expand Up @@ -433,7 +433,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase {
let floatingLabelTextFieldSpy = SkyFloatingLabelTextFieldSpy()

// when
_ = floatingLabelTextFieldSpy.becomeFirstResponder()
floatingLabelTextFieldSpy.becomeFirstResponder()

// then
XCTAssertTrue(floatingLabelTextFieldSpy.updateColorsInvoked)
Expand All @@ -444,7 +444,7 @@ class SkyFloatingLabelTextFieldTests: XCTestCase {
let floatingLabelTextFieldSpy = SkyFloatingLabelTextFieldSpy()

// when
_ = floatingLabelTextFieldSpy.resignFirstResponder()
floatingLabelTextFieldSpy.resignFirstResponder()

// then
XCTAssertTrue(floatingLabelTextFieldSpy.updateColorsInvoked)
Expand Down
2 changes: 2 additions & 0 deletions Sources/SkyFloatingLabelTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ open class SkyFloatingLabelTextField: UITextField {
Attempt the control to become the first responder
- returns: True when successfull becoming the first responder
*/
@discardableResult
override open func becomeFirstResponder() -> Bool {
let result = super.becomeFirstResponder()
self.updateControl(true)
Expand All @@ -325,6 +326,7 @@ open class SkyFloatingLabelTextField: UITextField {
Attempt the control to resign being the first responder
- returns: True when successfull resigning being the first responder
*/
@discardableResult
override open func resignFirstResponder() -> Bool {
let result = super.resignFirstResponder()
self.updateControl(true)
Expand Down