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 RxCocoa | |
import RxSwift | |
// MARK: - Reactive protocol | |
protocol ReactiveDisposable { | |
var disposeBag: DisposeBag { get } | |
} |
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 RxSwift | |
import RxCocoa | |
extension Reactive where Base: UIViewController { | |
public var viewDidLoad: Observable<Void> { | |
return self.sentMessage(#selector(UIViewController.viewDidLoad)).map({ _ in return () }) | |
} | |
public var viewWillAppear: Observable<Bool> { |
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
public typealias AlertViewClosure = (AlertView) -> Void | |
// MARK: - | |
public final class AlertView: UIView { | |
// MARK: - AlertViewButton | |
public struct Button { | |
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 | |
// MARK: - Protocol | |
public protocol Notifier { | |
associatedtype Notification: RawRepresentable | |
} | |
public extension Notifier where Notification.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
// | |
// KeyboardObserver.swift | |
// Product | |
// | |
// Created by muukii on 3/17/16. | |
// Copyright © 2016 eure. All rights reserved. | |
// | |
import Foundation | |
import RxSwift |
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
extension CollectionType { | |
/// Returns the first element where `predicate` returns `true` for the | |
/// corresponding value, or `nil` if such value is not found. | |
/// | |
/// - Complexity: O(`self.count`). | |
func firstMatching(@noescape predicate: (Self.Generator.Element) -> Bool) -> Self.Generator.Element? { | |
for (_, element) in self.enumerate() { | |
if predicate(element) { return element } | |
} |
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
extension Array { | |
var powerSet: [[Element]] { | |
guard !isEmpty else { return [[]] } | |
return Array(self[1...]).powerSet.flatMap { [$0, [self[0]] + $0] } | |
} | |
} | |
print([1,2,3,4].powerSet) // -> [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3], [4], [1, 4], [2, 4], [1, 2, 4], [3, 4], [1, 3, 4], [2, 3, 4], [1, 2, 3, 4]] |
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
// MARK: - NSUserDefaults | |
extension NSUserDefaults { | |
class func performOnceForKey(key: String, perform: () -> Void, elsePerform: (() -> Void)? = nil) { | |
let once = self.standardUserDefaults().objectForKey(key) | |
self.standardUserDefaults().setBool(true, forKey: key) | |
self.standardUserDefaults().synchronize() | |
if once == nil { perform() } |
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
extension CGPoint { | |
public enum CoordinateSystem { | |
case UIKit | |
case SpriteKit | |
} | |
public func coordinates(from from: CoordinateSystem, to: CoordinateSystem) -> CGPoint { | |
if from == to { return self } | |
else { |
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
struct Settings { | |
// Make sure to add the "-D DEBUG" flag in the project settings for the Swift Compiler | |
static var Debug: Bool { | |
#if DEBUG | |
return true | |
#else | |
return false | |
#endif | |
} |
NewerOlder