Skip to content

Instantly share code, notes, and snippets.

@Sherlouk
Sherlouk / DebugDevice.swift
Last active December 10, 2023 19:24
Debug Profiles - Securely debugging in production
//
// DebugDevice.swift
//
// Copyright 2022 • Sidetrack Tech Limited
//
import Foundation
// This must be called on the main-thread.
var isDebugProfileInstalled: Bool {
@beader
beader / InfiniteScrollChart.swift
Last active January 29, 2024 16:25
Infinite Scrollable Bar Chart using Swift Charts
//
// InfiniteScrollChart.swift
// ChartsGallery
//
// Created by beader on 2022/11/3.
//
import SwiftUI
import Charts
@mdb1
mdb1 / industry-related-reading.md
Last active November 11, 2023 08:30
Industry Related Reading
@vibrazy
vibrazy / Toggle.swift
Created May 10, 2021 10:56
Toggled - Simpler way to deal with hardcoded ViewModifers values in SwiftUI
struct ToggledExampleView_Previews: PreviewProvider {
static var previews: some View {
DebuggingToggledExampleView()
}
}
// MARK: - Toggled Source
protocol ToggleInterface {
associatedtype ValueType
@steipete
steipete / CombineHelper.swift
Created March 30, 2021 07:55
Combine helper that runs a Future after a delay on a background queue
import Foundation
import Combine
/// Run a block in the background with a delay and make it cancellable.
/// - Parameters:
/// - delay: Delay in milliseconds before the background work starts
/// - queue: Background queue to use
/// - worker: Worker block to execute on queue
/// - completion: Completion handler executed on main thread.
/// - Returns: AnyCancellable token
@ryanpato
ryanpato / XCUIElement+Wait.swift
Last active January 4, 2024 04:05
XCUIElement+Wait
//
// XCUIElement+Wait.swift
//
// Created by Ryan Paterson on 12/12/2020.
//
import XCTest
extension XCUIElement {
/// The period of time in seconds to wait explicitly for expectations.
import Foundation
public struct MockFunc<Input, Output> {
public var parameters: [Input] = []
public var result: (Input) -> Output = { _ in fatalError() }
public init() {}
public init(result: @escaping (Input) -> Output) {
self.result = result
import Combine
import ObjectiveC
import UIKit
private var eventSubjectKey = "viewcontroller_lifecycle_subject"
private var swizzlingPerformed = false
private final class LifecycleSubjectBag: NSObject {
let viewDidLoadSubject = PassthroughSubject<Void, Never>()
let viewWillAppearSubject = PassthroughSubject<Bool, Never>()
@levibostian
levibostian / AppCoreDataManager.swift
Last active October 6, 2023 18:02
iOS CoreData ultimate document. Stack, tutorial, errors could encounter. All my CoreData experience for what works in 1 document.
import CoreData
import Foundation
protocol CoreDataManager {
var uiContext: NSManagedObjectContext { get }
func newBackgroundContext() -> NSManagedObjectContext
func performBackgroundTaskOnUI(_ block: @escaping (NSManagedObjectContext) -> Void)
func performBackgroundTask(_ block: @escaping (NSManagedObjectContext) -> Void)
func loadStore(completionHandler: ((Error?) -> Void)?)
}