This file contains hidden or 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
///////////////// | |
// MyFramework // | |
///////////////// | |
// Instrument.swift | |
@objc public class Instrument: NSManagedObject { | |
} |
This file contains hidden or 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
// | |
// ViewController.swift | |
// ModalTest2 | |
// | |
// Created by Jayson Rhynas on 2018-11-21. | |
// Copyright © 2018 Jayson Rhynas. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or 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
git config --global diff.json.textconv "f() { cat \"${1}\" | jq --sort-keys .; }; f" |
This file contains hidden or 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: - Basic Implementation | |
struct SortDescriptor<Element> { | |
let compare: (Element, Element) -> ComparisonResult | |
} | |
private func compare<Element>(_ lhs: Element, _ rhs: Element, _ descriptors: [SortDescriptor<Element>]) -> Bool { | |
for descriptor in descriptors { |
This file contains hidden or 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
protocol EditorViewController { | |
associatedtype Item: EditableItem | |
var item: Item? { get set } | |
} | |
protocol EditableItem { | |
associatedtype Editor: EditorViewController & NSViewController | |
static var editorSceneId: NSStoryboard.SceneIdentifier { get } | |
} |
This file contains hidden or 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
class PassthroughContainer: UIView { | |
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | |
guard super.point(inside: point, with: event) else { | |
return false | |
} | |
for subview in self.subviews where subview.isUserInteractionEnabled { | |
let subPoint = self.convert(point, to: subview) | |
if subview.point(inside: subPoint, with: event) { | |
return true |
This file contains hidden or 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
enum Planet: Int { | |
case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune | |
} | |
struct PlanetOptions { | |
let planets: Set<Planet> | |
private init(_ planets: Set<Planet>) { | |
self.planets = planets | |
} |
This file contains hidden or 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
enum Planet: Int { | |
case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune | |
// case pluto | |
static var gasGiants: Set<Planet> = [.jupiter, .saturn] | |
} | |
let planet: Planet = .jupiter | |
if Planet.gasGiants.contains(planet) { |
This file contains hidden or 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 | |
class KVObserver: NSObject { | |
let subject: NSObject | |
let keyPath: String | |
let block: (Any?) -> Void | |
init(subject: NSObject, keyPath: String, block: @escaping (Any?) -> Void) { | |
self.subject = subject | |
self.keyPath = keyPath |
This file contains hidden or 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
protocol TrackProvider { | |
var track: Track? { get } | |
func observeTrack(_ block: (TrackProvider, NSKeyValueObservedChange<Track>)) -> NSKeyValueObservation | |
} | |
extension TrackProvider where Self: NSObject { | |
func observeTrack(_ block: (TrackProvider, NSKeyValueObservedChange<Track?>)) -> NSKeyValueObservation { | |
return self.observe(\TrackProvider.track) { obj, change in | |
} |