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: - | |
public struct PaginatedList<T: Decodable> { | |
// MARK: - Action | |
enum Mutation { | |
case created |
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
let fontFamilyNames = UIFont.familyNames | |
for familyName in fontFamilyNames { | |
print("------------------------------") | |
print("Font Family Name = [\(familyName)]") | |
let names = UIFont.fontNames(forFamilyName: familyName) | |
print("Font Names = [\(names)]") | |
} |
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
// 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 | |
} |
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 CGFloat { | |
var toRadians: CGFloat { | |
return self * CGFloat(M_PI) / 180.0 | |
} | |
var toDegress: CGFloat { | |
return self * 180 / CGFloat(M_PI) | |
} | |
} |
NewerOlder