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
| // MARK: - Storage.swift | |
| import CoreData | |
| public final class Storage { | |
| private let queue: DispatchQueue | |
| private let context: NSManagedObjectContext | |
| private let schema: StorageSchema | |
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 os | |
| internal enum Diagnostics { | |
| internal static let logger: OSLog = OSLog(subsystem: "com.company", category: "diagnostics") | |
| @inline(__always) | |
| internal static func log(_ type: OSLogType = .debug, _ message: StaticString) { | |
| os_log(type, log: logger, message) | |
| } |
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 class Foundation.NSTask.Process | |
| import class Foundation.Pipe | |
| import class Foundation.FileHandle | |
| import struct Foundation.NSData.Data | |
| import class Foundation.NSLock.NSConditionLock | |
| public final class Command { | |
| public var isRunning: Bool { lock.condition == 1 } | |
| public var isCompleted: Bool { lock.condition == 0 } |
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 UIKit | |
| public final class TouchCaptureWindow: UIWindow { | |
| fileprivate lazy var presentationWindow: TouchPresentationWindow = { [unowned self] in | |
| if #available(iOS 13.0, *) { | |
| guard let scene = self.windowScene else { return TouchPresentationWindow(frame: self.frame) } | |
| return TouchPresentationWindow(windowScene: scene) | |
| } else { | |
| return TouchPresentationWindow(frame: self.frame) |
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
| public final class CardsView: UIView { | |
| private enum Constants { | |
| static let margins = UIEdgeInsets(top: 8, left: spacing / 2, bottom: 8, right: spacing / 2) | |
| static let spacing = CGFloat(16) | |
| } | |
| private lazy var scrollView = UIScrollView() | |
| private lazy var stackView = UIStackView() | |
| public var previousPageHandler: (() -> Array<CardViewModel>)? { |
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 UIKit | |
| public final class TextView: UITextView { | |
| public override init(frame: CGRect, textContainer: NSTextContainer?) { | |
| super.init(frame: frame, textContainer: textContainer) | |
| layoutManager.delegate = self | |
| isScrollEnabled = false | |
| } | |
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
| extension NSLayoutManager { | |
| var numberOfLines: Int { | |
| var linesCount: Int = 0 | |
| var idx: Int = 0 | |
| let lineRange: NSRangePointer = .allocate(capacity: 1) | |
| while idx < numberOfGlyphs { | |
| lineFragmentRect(forGlyphAt: idx, effectiveRange: lineRange) | |
| idx = NSMaxRange(lineRange.pointee) | |
| linesCount += 1 | |
| } |
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
| struct SomeType { | |
| private var store: Any = 0 // or something else to proxy properties | |
| var value: Any { | |
| @available(*, unavailable) | |
| get { fatalError("unavailable") } | |
| set { store = newValue} | |
| } | |
| } |
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
| e print(String(data: JSONSerialization.data(withJSONObject: JSONSerialization.jsonObject(with: data, options: []), options: .prettyPrinted), encoding: .utf8)!) |
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 UIKit | |
| extension UIResponder { | |
| private static weak var _currentFirstResponder: UIResponder? | |
| public static var currentFirstResponder: UIResponder? { | |
| dispatchPrecondition(condition: .onQueue(.main)) | |
| _currentFirstResponder = nil | |
| UIApplication.shared.sendAction(#selector(UIResponder.findFirstResponder(_:)), to: nil, from: nil, for: nil) |