Skip to content

Instantly share code, notes, and snippets.

View yageek's full-sized avatar
🥨

Yannick Heinrich yageek

🥨
View GitHub Profile
import Foundation
public class Disposable {
private var isDisposed = false
private let _dispose: () -> Void
public func dispose() {
if !isDisposed {
_dispose()
isDisposed = true
}
@levibostian
levibostian / AppCoreDataManager.swift
Last active January 25, 2025 07:44
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)?)
}
@alexito4
alexito4 / AutoMockable.stencil
Created August 4, 2020 07:55
Sourcery templates for automatic mocks from a concrete type
// swiftlint:disable line_length
// swiftlint:disable variable_name
import Foundation
#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
import RxSwift
import SwiftUI
import MapKit // be sure to import MapKit
import PlaygroundSupport
struct ContentView: View {
var body: some View {
ZStack {
MapView()
VStack {
@serhiybutz
serhiybutz / code.swift
Last active July 22, 2024 14:00
Combine: withLatestFrom, 04
import Combine
extension Publishers {
public struct WithLatestFrom<Upstream: Publisher, Other: Publisher>:
Publisher where Upstream.Failure == Other.Failure
{
// MARK: - Types
public typealias Output = (Upstream.Output, Other.Output)
public typealias Failure = Upstream.Failure
@IsaacXen
IsaacXen / README.md
Last active May 14, 2025 17:11
(Almost) Every WWDC videos download links for aria2c.
//
// SAWKWebView.swift
//
// Created by Costantino Pistagna on 24/01/2020.
// Copyright © 2020 Sofapps. All rights reserved.
//
import UIKit
import WebKit
@vinczebalazs
vinczebalazs / SheetModalPresentationController.swift
Last active July 21, 2024 15:36
A presentation controller to use for presenting a view controller modally, which can be dismissed by a pull down gesture. The presented view controller's height is also adjustable.
import UIKit
extension UIView {
var allSubviews: [UIView] {
subviews + subviews.flatMap { $0.allSubviews }
}
func firstSubview<T: UIView>(of type: T.Type) -> T? {
allSubviews.first { $0 is T } as? T
//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
// SwiftUI Custom Styles (TripleToggleStyle)
// https://swiftui-lab.com
// https://swiftui-lab.com/custom-styling
import SwiftUI
// MARK: - TripleToggle View
public struct TripleToggle: View {
@Environment(\.tripleToggleStyle) var style: AnyTripleToggleStyle