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
extension UIControl { | |
/// Typealias for UIControl closure. | |
public typealias UIControlTargetClosure = (UIControl) -> () | |
private class UIControlClosureWrapper: NSObject { | |
let closure: UIControlTargetClosure | |
init(_ closure: @escaping UIControlTargetClosure) { | |
self.closure = closure | |
} |
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 Foundation | |
struct BigInt { | |
var value: String | |
func multiply(right: BigInt) -> BigInt { | |
var leftCharacterArray = value.characters.reversed().map { Int(String($0))! } | |
var rightCharacterArray = right.value.characters.reversed().map { Int(String($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
extension UITableView { | |
public func dequeue<T: UITableViewCell>(cellClass: T.Type) -> T? { | |
return dequeueReusableCell(withIdentifier: cellClass.reuseIdentifier) as? T | |
} | |
public func dequeue<T: UITableViewCell>(cellClass: T.Type, forIndexPath indexPath: IndexPath) -> T { | |
guard let cell = dequeueReusableCell( | |
withIdentifier: cellClass.reuseIdentifier, for: indexPath) as? T else { | |
fatalError( |
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
extension UITableView { | |
public func register<T: UITableViewCell>(cellClass: T.Type) { | |
register(cellClass, forCellReuseIdentifier: cellClass.reuseIdentifier) | |
} | |
} |
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
extension UITableViewCell { | |
static var reuseIdentifier: String { | |
return NSStringFromClass(self) | |
} | |
} |
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 button = UIButton() | |
button.addAction(for: .touchUpInside) { (button) in | |
// Run code | |
} | |
let slider = UISlider() | |
slider.addAction(for: .valueChanged) { (slider) in | |
// Run code | |
} |
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 view = WorldView(worldSize: 100, cellSize: 5) | |
view.autoRun() | |
PlaygroundPage.current.liveView = view |
NewerOlder