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
struct CustomViewModel { | |
let data: String | |
init(data: String) { | |
self.data = data | |
} | |
} | |
final class CustomViewController: ViewController<CustomViewModel> { | |
override func viewDidLoad() { |
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
import UIKit | |
print(DerivedViewController.self) | |
// The following is required because there's an impedence mismatch between | |
// `CommandLine` and `UIApplicationMain` <rdar://problem/25693546>. | |
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory( | |
to: UnsafeMutablePointer<Int8>.self, | |
capacity: Int(CommandLine.argc) | |
) |
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
import UIKit | |
public class ViewController<T>: UIViewController { | |
var viewModel: T! | |
override public func viewDidLoad() { | |
super.viewDidLoad() | |
assertViewModel() | |
} | |
} |
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
struct CustomViewModel { | |
let data: String | |
init(data: String) { | |
self.data = data | |
} | |
} | |
final class CustomViewController: ViewController<CustomViewModel> { | |
override func viewDidLoad() { |
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
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
super.prepare(for: segue, sender: sender) | |
guard | |
let viewController = segue.destination as? CustomViewController | |
else { return } | |
// compiler knows that CustomViewModel is our view model type | |
viewController.viewModel = CustomViewModel(data: "hello") | |
} |
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
import UIKit | |
// reference each view controller before UIApplicationMain runs | |
print(CustomViewController.self) | |
// The following is required because there's an impedence mismatch between | |
// `CommandLine` and `UIApplicationMain` <rdar://problem/25693546>. | |
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory( | |
to: UnsafeMutablePointer<Int8>.self, | |
capacity: Int(CommandLine.argc) |
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
module.exports = { | |
"env": { | |
"browser": false, | |
"node": true, | |
"es6": true, | |
"mocha": true, | |
}, | |
"rules": { | |
"no-param-reassign": [2, { "props": false }], | |
"no-console":0, |
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
import Foundation | |
import PlaygroundSupport | |
let apiKey = "[API KEY]" | |
let endPointUrl = "https://westus.api.cognitive.microsoft.com/emotion/v1.0" | |
let url = URL(string: "\(endPointUrl)/recognize")! | |
let testImageString = "https://pbs.twimg.com/profile_images/853106910861643776/tZh0rhmL.jpg" | |
struct Response: Decodable { | |
let scores: Score |
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
// | |
// LivePhotoUtil.swift | |
// Blink | |
// | |
// Created by Shane Vitarana on 6/2/17. | |
// Copyright © 2017 Blink. All rights reserved. | |
// | |
import Alamofire | |
import BlinkApi |
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
import Foundation | |
import PlaygroundSupport | |
let apiKey = API_KEY | |
let endPointUrl = "https://westus.api.cognitive.microsoft.com/emotion/v1.0" | |
let url = URL(string: "\(endPointUrl)/recognize")! | |
let testImageString = TEST_IMAGE | |
struct Response: Decodable { | |
let scores: Score |