This file contains hidden or 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
// | |
// Parser | |
// | |
// | |
struct Parser<T: Decodable> { | |
static func parse(_ data: Data) -> T? { | |
var parsedPayload: T? | |
do { | |
parsedPayload = try JSONDecoder().decode(T.self, from: data) |
This file contains hidden or 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
extension XCUIElement { | |
func clearText() { | |
// | |
// cf. and tip courtesy of | |
// https://stackoverflow.com/questions/32821880/ui-test-deleting-text-in-text-field | |
// | |
guard let stringValue = self.value as? String else { |
This file contains hidden or 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
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to | |
// match the height of the content's scrollHeight | |
// | |
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called | |
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { | |
if webView.isLoading == false { | |
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in | |
if let height = result as? CGFloat { |
This file contains hidden or 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
func setupTabBarWithSearchContainerView() { | |
// configure a UIViewController to display search results | |
// needs to conform to the UISearchResultsUpdating protocol | |
let searchResultsViewController = SearchResultsViewController() | |
// setup UISearchController and hook up to search results UIViewController | |
let searchController = UISearchController(searchResultsController: searchResultsViewController) | |
searchController.searchResultsUpdater = searchResultsViewController | |
searchController.hidesNavigationBarDuringPresentation = false |