Skip to content

Instantly share code, notes, and snippets.

View sandofsky's full-sized avatar

Benjamin Sandofsky sandofsky

View GitHub Profile
typealias Callback = () -> ()
// Both methods are required
class Something {
var calledOnce:Callback?
var calledMultipleTimes:Callback?
}
import UIKit
protocol StoryboardBacked:class {
static func newFromStoryboardWithName(name:String?, bundle:NSBundle?) -> Self
}
extension StoryboardBacked {
static func newFromStoryboardWithName(name:String?, bundle:NSBundle?) -> Self {
let realName = name ?? NSStringFromClass(self as AnyClass).componentsSeparatedByString(".").last!
let storyboard = UIStoryboard(name: realName, bundle: bundle)
import AVFoundation
import UIKit
class ViewController: UIViewController {
var discoverSession:MyDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera, .builtInWideAngleCamera, .builtInTelephotoCamera], mediaType: .video, position: .back)
@IBAction func didTapCrashButton(_ sender: Any) {
let devices = discoverSession.myDevices
print("Got devices: \(devices)")