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 Foo { } | |
enum Bar { | |
case hero(Any) | |
} | |
let foo = Foo() | |
let bar = Bar.hero(foo) | |
if case let .hero(foo) = bar, foo is Foo { |
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
//: | |
//: UIView Animation Syntax Sugar | |
//: | |
//: Created by Andyy Hope on 18/08/2016. | |
//: Twitter: @andyyhope | |
//: Medium: Andyy Hope, https://medium.com/@AndyyHope | |
import UIKit | |
extension UIView { |
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
//: | |
//: UserDefaultable.swift | |
//: | |
//: Created by Andyy Hope on 18/08/2016. | |
//: Twitter: @andyyhope | |
//: Medium: Andyy Hope, https://medium.com/@AndyyHope | |
import Foundation | |
// MARK: - Key Namespaceable |
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
// Swift: Typecasing | |
// Enums as data models? | |
// | |
// Author: Andyy Hope | |
// Twitter: @andyyhope | |
// Medium: medium.com/@andyyhope | |
import Foundation | |
// MARK: - Models |
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
// Swift: Syntax Cheat Codes | |
// ↑ ↑ ↓ ↓ ← → ← → B A | |
// | |
// Author: Andyy Hope | |
// Twitter: @andyyhope | |
// Medium: medium.com/@andyyhope | |
import UIKit |
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
static func addObserver(observer: AnyObject, selector: Selector, notification: Notification) { | |
let name = nameFor(notification) | |
NSNotificationCenter.defaultCenter() | |
.addObserver(observer, selector: selector, name: name, object: nil) | |
} |
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
static func removeObserver(observer: AnyObject, notification: Notification, object: AnyObject? = nil) { | |
let name = nameFor(notification) | |
NSNotificationCenter.defaultCenter() | |
.removeObserver(observer, name: name, object: object) | |
} |
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
private static func nameFor(notification: Notification) -> String { | |
return "\(self).\(notification.rawValue)" | |
} |
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
static func postNotification(notification: Notification, object: AnyObject? = nil, userInfo: [String : AnyObject]? = nil) { | |
let name = nameFor(notification) | |
NSNotificationCenter.defaultCenter() | |
.postNotificationName(name, object: object, userInfo: userInfo) | |
} |
NewerOlder