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 | |
import os.log | |
protocol Logger { | |
func error(_ error: String) | |
func warning(_ warning: String) | |
func event(_ event: String) | |
func message(_ message: 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
import Foundation | |
extension Float { | |
var toOneDecimalPlace: String { String(format: "%.1f", self) } | |
} |
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 | |
extension DateFormatter { | |
static let mediumDateTimeFormatter: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.timeZone = TimeZone.current | |
formatter.dateStyle = .medium | |
formatter.timeStyle = .medium | |
return formatter |
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 Combine | |
import Foundation | |
// MARK: - Supporting Models: Once per codebase | |
enum HTTPMethod: String { | |
case delete | |
case get | |
case post |
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 SwiftUI | |
struct OverlayView<OverlayContent: View>: ViewModifier { | |
@Binding var isPresented: Bool | |
var modalContent: OverlayContent | |
var transition: AnyTransition = .move(edge: .bottom) | |
var animation: Animation = .easeInOut | |
func body(content: Content) -> some View { |
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 Combine | |
import SwiftUI | |
struct IfNotNil<Value, Content>: View where Content: View { | |
private let value: Value? | |
private let content: (Value) -> Content | |
init(_ value: Value?, | |
@ViewBuilder show content: @escaping (Value) -> Content) { |
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 XCTest | |
import Realm | |
import RealmSwift | |
class ProofOfConceptTests: RealmTestCase { | |
// NOTE this is for objects with 1-to-1 relationships | |
func testUpdateAsset() { | |
// 1. make a full object | |
let city = City() |
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 | |
class Bakery { | |
func bakeCake() -> Cake? { | |
let ingredientStorage = IngredientStorage() | |
if let chocolateFlavor = ingredientStorage.consume(flavor: .chocolate) { | |
return Cake(flavor: chocolateFlavor) | |
} else if let vanillaFlavor = ingredientStorage.consume(flavor: .vanilla) { | |
return Cake(flavor: vanillaFlavor) | |
} |
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 | |
/* | |
This is used by NSNotification.Name to allow enum-like members, | |
but where new members can be added in an extension! | |
enum Directions: String { | |
case north = "North" | |
} | |
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/Foundation.h> | |
#define dep(p) [[Registry shared] resolve: (@protocol(p))] | |
#define reg(c, p) [[Registry shared] register:[c class] forProtocol:@protocol(p)] | |
@interface Registry : NSObject | |
@property (nonatomic, strong) NSMutableDictionary * _Nonnull classRegister; | |
@property (nonatomic, strong) NSMutableDictionary * _Nonnull classInstances; | |
+(instancetype _Nonnull)shared; | |
- (id _Nullable)resolve:(Protocol * _Null_unspecified)aProtocol; |
NewerOlder