Last active
November 19, 2016 04:47
-
-
Save klundberg/cb6d5205feb180c37345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
// error: 'UISearchController' is only available on iOS 8.0 or newer | |
var searchController: UISearchController? | |
// error: Stored properties cannot be marked potentially unavailable with 'introduced=' | |
@available(iOS 8.0, *) | |
var conditionallyAvailableSearchController: UISearchController? | |
// Workaround that works | |
private var _searchController: UIViewController? | |
@available(iOS 8.0, *) | |
private var workingSearchController: UISearchController? { | |
get { | |
return _searchController as? UISearchController | |
} | |
set { | |
_searchController = newValue | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't mark the class as @available(iOS 8.0, *) since the class i'm encountering this in needs to work on iOS 7 too.