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 Foundation | |
/// Stores many weak-referenced closures, and may call all in once | |
/// Throwing closures are not allowed | |
public struct ClosureSystem<P, R> { | |
/// The type of a single closure | |
public typealias ClosureType = (P) -> R | |
private var elements: [WeakReference<Reference<ClosureType>>] | |
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 | |
protocol SegueHandlerType { | |
typealias SegueIdentifier: RawRepresentable | |
} | |
extension SegueHandlerType where | |
Self: UIViewController, | |
SegueIdentifier.RawValue == String | |
{ |
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 | |
extension UIImage { | |
enum AssetIdentifier: String { | |
case AppIcon = "AppIcon" | |
case DefaultCover = "default-cover" | |
} | |
convenience init!(assetIdentifier: AssetIdentifier) { |
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 Foundation | |
func delay(delay:Double, closure:()->()) { | |
dispatch_after( | |
dispatch_time( | |
DISPATCH_TIME_NOW, | |
Int64(delay * Double(NSEC_PER_SEC)) | |
), | |
dispatch_get_main_queue(), closure) | |
} |
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 AVFoundation | |
public typealias AVMediaType = String | |
public extension AVCaptureDevice { | |
public class func device(mediaType: AVMediaType, position: AVCaptureDevicePosition) -> AVCaptureDevice? { | |
let all = AVCaptureDevice.devicesWithMediaType(mediaType) as! [AVCaptureDevice] | |
for dev in all { | |
if dev.position == position { |
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 Foundation | |
protocol Localized { | |
typealias RawType | |
var localized: RawType { get } | |
} | |
enum LocalizedString: String, Localized { | |
case FailureXXXAuthorizationTitle = "FailureXXXAuthorizationTitle" |
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 | |
public extension UITapGestureRecognizer { | |
public var location: CGPoint { | |
return self.locationInView(self.view) | |
} | |
} |
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 | |
import AVFoundation | |
class CameraPreviewView: UIView { | |
override class func layerClass() -> AnyClass { | |
return AVCaptureVideoPreviewLayer.self | |
} | |
var session: AVCaptureSession! { |
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 AVFoundation | |
public extension AVCaptureSession { | |
public func configuration(operation: () -> ()) { | |
self.beginConfiguration() | |
operation() | |
self.commitConfiguration() | |
} | |
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 | |
import AVFoundation | |
public extension AVCaptureVideoOrientation { | |
public init(interfaceOrientation: UIInterfaceOrientation) { | |
switch interfaceOrientation { | |
case .Unknown: | |
self = .LandscapeLeft | |
case .Portrait: |
OlderNewer