Skip to content

Instantly share code, notes, and snippets.

self.viewController = MoviesViewController()
self.navigationController.pushViewController(self.viewController, animated: false)
{
"title": "Movie Title",
"year": "2017",
"genre": [
"Action",
"Adventure"
]
}
import Foundation
struct Movie {
let title: String
let year: String
let genre: [String]
init(title: String, year: String, genre: [String]) {
private func fetchMovies(onSuccess: ([Movie]) -> Void) {
let exampleMovie = Movie(title: "Movie title", year: "2017", genre: ["Action", "Adventure"])
onSuccess([exampleMovie])
}
private func convert(movies: [Movie]) -> MoviesViewModel {
let movieCellViewModels = movies.map { movie in
MovieCellViewModel(
textLabel: "\(movie.title) (\(movie.year))",
detailTextLabel: movie.genre.joined(separator: ", ")
)
}
import Foundation
import UIKit
final class MoviesViewCoordinator {
// MARK: - Instance dependencies
private let navigationController: UINavigationController
// MARK: - Instance state
import Foundation
import UIKit
final class AppCoordinator {
private let navigationController: UINavigationController
private var childCoordinator: MoviesViewCoordinator!
init(navigationController: UINavigationController) {
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appCoordinator: AppCoordinator!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
addUIInterruptionMonitor(withDescription: "Camera permission dialog") { (alert) -> Bool in
if alert.label == "“Application” Would Like to Access the Camera" {
alert.buttons["OK"].tap()
self.app.swipeUp()
self.app.swipeDown()
return true
}
// Run in chrome console whilst on the stats page
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);