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 Combine | |
struct MyObject { | |
var string: String | |
} | |
class MyClass { | |
var cancellable: AnyCancellable? |
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 vc = UIViewController() | |
vc.view.backgroundColor = .white | |
PlaygroundPage.current.liveView = vc | |
let replicatorLayer = CAReplicatorLayer() | |
vc.view.backgroundColor = UIColor.blue | |
vc.view.layer.addSublayer(replicatorLayer) | |
let size: CGFloat = 100 | |
let viewFrame = vc.view.frame |
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 vc = UIViewController() | |
vc.view.backgroundColor = .white | |
PlaygroundPage.current.liveView = vc | |
//Creating the replicator layer | |
let replicatorLayer = CAReplicatorLayer() | |
vc.view.layer.addSublayer(replicatorLayer) | |
let size: CGFloat = 100 | |
let viewFrame = vc.view.frame |
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
/// Calls a function n times passing the result of each call into the next call. | |
/// | |
/// - Parameters: | |
/// - function: A function that takes T and returns T. It will be called multiple times and produce the result. | |
/// - initialInput: The initial input to pass into the function. | |
/// - repetitions: The number of times the function has to be called. | |
/// - Returns: Returns the result of consecutive calls to the given functions. | |
func call<T>(_ function: @escaping (T) -> T?, initialInput: T, repetitions: Int) -> T? { | |
var seq = sequence(first: initialInput, next: function) | |
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
/// | |
/// - Parameters: | |
/// - popoverContent: the view controller to add as a popover. | |
/// - sourcePoint: the point in which to anchor the popover. | |
/// - size: the size of the popover. Default uses the popover preferredContentSize. | |
/// - delegate: the popover's presentationController delegate. Default is nil. | |
/// - animated: Pass true to animate the presentation; otherwise, pass false. | |
/// - completion: The block to execute after the presentation finishes. Default is nil. | |
public func presentPopover(_ popoverContent: UIViewController, sourcePoint: CGPoint, size: CGSize? = nil, delegate: UIPopoverPresentationControllerDelegate? = nil, animated: Bool = true, completion: (() -> Void)? = nil) { | |
popoverContent.modalPresentationStyle = .popover |