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
// First, install InjectionIII.app from the Mac AppStore | |
// https://apps.apple.com/us/app/injectioniii/id1380446739?mt=12 | |
// Make these changes to your code: | |
// add the following to application(didFinishLaunchingWithOptions:) | |
#if DEBUG | |
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load() | |
#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
import UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
let window = UIWindow(frame: UIScreen.main.bounds) |
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 protocol ReflectedStringConvertible : CustomStringConvertible { } | |
extension ReflectedStringConvertible { | |
public var description: String { | |
let mirror = Mirror(reflecting: self) | |
var str = "\(mirror.subjectType)(" | |
var first = true | |
for (label, value) in mirror.children { | |
if let label = label { |
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 Dictionary where Value: Equatable { | |
/// Returns all keys mapped to the specified value. | |
/// ``` | |
/// let dict = ["A": 1, "B": 2, "C": 3] | |
/// let keys = dict.keysForValue(2) | |
/// assert(keys == ["B"]) | |
/// assert(dict["B"] == 2) | |
/// ``` | |
func keysForValue(value: Value) -> [Key] { | |
return flatMap { (key: Key, val: Value) -> Key? in |
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 Cocoa | |
// Support Foundation calls on String | |
public extension String { public var ns: NSString {return self as NSString} } | |
/// Custom Labeled Playground-Based Drag-and-Drop window | |
public class DropView: NSTextField { | |
// Default action handler | |
public var handler: ([String]) -> Void = { paths in Swift.print(paths) } |
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
/* | |
ericasadun.com | |
Super-basic priority-less layout utilities | |
*/ | |
#if os(iOS) | |
import UIKit | |
#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
You can use enum and protocol extension to provide GCD convenience API: | |
``` | |
protocol ExcutableQueue { | |
var queue: dispatch_queue_t { get } | |
} | |
extension ExcutableQueue { | |
func execute(closure: () -> Void) { | |
dispatch_async(queue, closure) | |
} |