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

Added availability check to use it with iOS7 #51

Merged
merged 2 commits into from
May 27, 2016
Merged

Added availability check to use it with iOS7 #51

merged 2 commits into from
May 27, 2016

Conversation

acecilia
Copy link
Contributor

Fix to use the textField in iOS7 (by downloading and adding the source
code to the project)

Fix to use the textField in iOS7 (downloading and adding the source
code to the project)
@RuiAAPeres
Copy link

You can remove the else {}.

super.prepareForInterfaceBuilder()
if #available(iOS 8.0, *) {
super.prepareForInterfaceBuilder()
} else {}
Copy link
Contributor

@gergelyorosz gergelyorosz May 27, 2016

Choose a reason for hiding this comment

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

+1 on what @RuiAAPeres said. Could you remove this empty else {} please, and it will be good to go 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Hell, how I missed that xD

@gergelyorosz
Copy link
Contributor

Perfect, thanks for the improvement @acecilia 👍 !

@gergelyorosz gergelyorosz merged commit 73042be into Skyscanner:master May 27, 2016
@intonarumori
Copy link
Contributor

Can we get some context of why we needed this, can we link an issue?

The preferred way to check API availability is respondsToSelector not hardcoding ios versions, is there any reason not to use it here?
https://www.raywenderlich.com/42591/supporting-multiple-ios-versions-and-devices

@RuiAAPeres
Copy link

@intonarumori that article is from 2013. From Apple's blog:

Availability: Using the latest SDKs ensures you get access to new features and information about platform changes. But sometimes you still need to target an older OS, and Swift makes doing so much easier and safer. The Swift compiler now shows an error when you use an API that is too new for your target OS, and #available blocks can safely wrap lines of code to only run when on the right OS versions.

@intonarumori
Copy link
Contributor

@RuiAAPeres Thanks for the link, seems less articulate to me but you are right this is the way forward.

Shouldn't we just use it for the whole method then?
Only having the super call in the condition seems weird to me, especially since super is required to be called.
Using it on the whole func would articulate the intent better imho.

@available(iOS 8, *)
override public func prepareForInterfaceBuilder() {
        super.prepareForInterfaceBuilder()
        self.selected = true
        _renderingInInterfaceBuilder = true
        self.updateControl(false)
        self.invalidateIntrinsicContentSize()
    }

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.

4 participants