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
protocol CancelableTask: Sendable { | |
var hashValue: Int { get } | |
func cancel() | |
} | |
extension Task: CancelableTask {} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
let hashTable = NSHashTable<NSMutableData>(options: .copyIn) | |
var str: NSMutableData? = NSMutableData.init() | |
hashTable.add(str) | |
str = nil | |
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { |
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
let hashTable = NSHashTable<NSString>.weakObjects() | |
var str: NSMutableString? = NSMutableString.init(string: "dasdasdas") | |
hashTable.add(str) | |
str = nil | |
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { |
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
class Test: NSObject { | |
deinit { | |
print("deinit") | |
} | |
} | |
let tests = NSHashTable<Test>.weakObjects() | |
var test: Test? = Test() | |
tests.add(test) |
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
final class Test { | |
deinit { | |
print("Deinited") | |
} | |
} | |
let hashTable: NSHashTable<Test> = .weakObjects() | |
var optionalInstance: Test? = Test() |
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 UIKit | |
import Combine | |
protocol UIControlPublishable: UIControl {} | |
extension UIControlPublishable { | |
func publisher(for event: UIControl.Event) -> UIControl.InteractionPublisher<Self> { | |
return InteractionPublisher(control: self, event: event) |
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
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
extension Publisher where Self.Failure == Never { | |
func assign(to failablePublished: CurrentValuePublished<Self.Output,Self.Failure>) -> AnyCancellable { | |
self.assign(to: \.wrappedValue, on: failablePublished) | |
} | |
} | |
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) |
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 | |
infix operator ->>: DefaultPrecedence | |
public protocol Castable { | |
func forceCast<U>(to type: U.Type) -> U | |
func AS<U>(to type: U.Type) -> U? |
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 CoreData | |
import Foundation | |
class CDPublisher<Entity>: NSObject, NSFetchedResultsControllerDelegate, Publisher where Entity: NSManagedObject { | |
typealias Output = [Entity] | |
typealias Failure = Error | |
private let request: NSFetchRequest<Entity> | |
private let context: NSManagedObjectContext |
NewerOlder