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
/// Parses a csv string and returns a 2d array. | |
/// | |
/// Size of the array will be equal to the number of rows. | |
/// And Size of the subarray will be equal to the | |
/// number of fields. | |
/// | |
/// Note: Delimiter can be changed to a different character | |
/// like semicolon. | |
func parse(string: String, delimiter: Character = ",") -> [[String]]{ | |
let rows = string.split(separator: "\n") |
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
/// Kicks off the main loop over the async sequence. Does the main work within the for loop over the async seqence | |
/// - Parameters: | |
/// - seq: The AsyncSequence that is the source | |
/// - sub: The Subscriber to this Subscription | |
private func mainLoop(seq: AsyncSequenceType, sub: S) { | |
// taskHandle is kept for cancelation | |
taskHandle = Task { | |
do { | |
try await withTaskCancellationHandler { | |
Task.detached { |
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 PublisherAsyncSequence { | |
public class Iterator { | |
private let iActor = InnerActor() | |
/// Due to bug [SR-14875](https://bugs.swift.org/browse/SR-14875) we need to avoid calling continuations | |
/// from the actor execution context currently which is why we wrap the state in this InnerActor instead of just making the Interator | |
/// and actor | |
private actor InnerActor { | |
/// These typealiases are just for cleaner call sites |
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 XCTest | |
class TestAsyncFileReadPerformanceTests: XCTestCase { | |
let bundle = Bundle(for: TestAsyncFileReadPerformanceTests.self) | |
lazy var bigFileUrl: URL = { | |
bundle.url(forResource: "randomData", withExtension: "txt")! | |
}() | |
lazy var smallFileUrl: URL = { | |
bundle.url(forResource: "dataJun-14-2021", withExtension: "json")! | |
}() |
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
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. | |
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene. | |
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). | |
// Use a UIHostingController as window root view controller | |
guard let scene = scene as? UIWindowScene else { return assertionFailure() } | |
let window = UIWindow(windowScene: scene) | |
configure( | |
window: window, |
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 class ListContent : NSManagedObject, BindableObject { | |
public let didChange = PassthroughSubject<Void, Never>() | |
private var changePublisher: PassthroughSubject<Void, Never> { | |
return didChange | |
} | |
override public func didChangeValue(forKey key: String) { | |
super.didChangeValue(forKey: key) | |
self.changePublisher.send(()) | |
} |
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
// | |
// FetchedResultsControllerPublisher.swift | |
// ListsModel | |
// | |
// Created by Joseph Lord on 09/06/2019. | |
// Copyright © 2019 Joseph Lord. All rights reserved. | |
// | |
import Foundation | |
import Combine |
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 | |
class MyView: UIView {} | |
protocol MyProtocol { | |
var view: UIView { get } | |
func myFunc() | |
} | |
extension MyProtocol { |
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 Foundation | |
private let testSize = 100_000_000 | |
private var testTime:CFAbsoluteTime = 0 | |
private var optimisedTestTime:CFAbsoluteTime = 0 | |
class Test | |
{ | |
func testing2(var x : Int) -> Int | |
{ |
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 | |
class GenericTVCDelegate<A> : NSObject { | |
var cellCreator:A->UITableViewCell | |
var data:[A] | |
init(cellCreator:A->UITableViewCell, data:[A]) { | |
self.cellCreator = cellCreator | |
self.data = data | |
} | |
} |
NewerOlder