Skip to content

Instantly share code, notes, and snippets.

@aryaxt
aryaxt / KeyboardManager
Created August 21, 2016 22:08
KeyboardManager
public class KeyboardManager {
public struct KeyboardChange {
public let visibleHeight: CGFloat
public let endFrame: CGRect
public let animationDuration: TimeInterval
public let animationOptions: UIViewAnimationOptions
}
public typealias KeyboardChangeClosure = (KeyboardChange)->Void
@aryaxt
aryaxt / Swift auto object serialization
Last active November 4, 2016 19:15
Swift auto object serialization
public protocol Serializable {
func serialize() -> [String: Any]
}
extension Serializable {
public func serialize() -> [String: Any] {
return Self.makeSerialized(serializable: self)
}
@aryaxt
aryaxt / Swift Identifiable protocol
Created November 1, 2016 04:20
Swift Identifiable protocol
// This allows you to implement identifiable on any class/struct and automatially make them Equatable
protocol Identifiable: Equatable {
var id: Int { get }
}
func == <T: Identifiable>(lhs: T, rhs: T) -> Bool {
return lhs.id == rhs.id
}