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 testFeaturedTopics() { | |
| let count = 200 | |
| for index in 0..<count { | |
| FeaturedTopics.shared[String(index)] = index | |
| } | |
| // The dispatch queue executes the submitted blocks in parallel and waits for all iterations to complete before returning | |
| DispatchQueue.concurrentPerform(iterations: count) { (index) in | |
| if let indexNumber = FeaturedTopics.shared[String(index)] as? Int { | |
| print(indexNumber) |
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
| final class FeaturedTopics { | |
| private var topics: [String: Any] = [:] | |
| static let shared = FeaturedTopics() | |
| private init() {} | |
| subscript(key: String) -> Any? { | |
| get { | |
| return topics[key] |
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 UIView { | |
| @inline(__always) static func build<T>(applyAttributes: ((T) -> Void)? = nil) -> T where T: UIView { | |
| let uiComponent = T(frame: .zero) | |
| uiComponent.translatesAutoresizingMaskIntoConstraints = false | |
| applyAttributes?(uiComponent) | |
| return uiComponent | |
| } | |
| } | |
| let label: UILabel = { |
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 UILabel { | |
| static func build(block: ((UILabel) -> Void)) -> UILabel { | |
| let label = UILabel(frame: .zero) | |
| label.translatesAutoresizingMaskIntoConstraints = false | |
| block(label) | |
| return label | |
| } | |
| } | |
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
| protocol ScopeFunc {} | |
| extension ScopeFunc { | |
| @inline(__always) func apply(block: (Self) -> ()) -> Self { | |
| block(self) | |
| return self | |
| } | |
| } | |
| class URLBuilder: ScopeFunc { | |
| private var components = URLComponents() |
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
| struct OptionDetailDataStruct: Equatable { | |
| let isExpired: Bool | |
| let expiryDate: String? | |
| let cardNumber: String? | |
| let formattedNumber: String? | |
| let phoneNumber: String? | |
| } | |
| class OptionDetailDataBuilderStruct { | |
| private var isExpired: Bool = false |
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
| class OptionDetailData: Equatable { | |
| var isExpired: Bool = false | |
| var expiryDate: String? | |
| var cardNumber: String? | |
| var formattedNumber: String? | |
| var phoneNumber: String? | |
| static func == (lhs: OptionDetailData, rhs: OptionDetailData) -> Bool { | |
| return true | |
| } |
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
| enum PaymentMethod { | |
| case creditCard | |
| case debitCard | |
| case wallet | |
| case cash | |
| } | |
| protocol PaymentPresenterStrategy {} | |
| protocol MethodsPresenterResolvable { |
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 | |
| protocol Cloneable { | |
| func copy() -> Any | |
| } | |
| class Message: Cloneable { | |
| var to: String | |
| var subject: String | |
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 ListViewController: UIViewController { | |
| let label = UILabel(frame: CGRect(x: 100, y: 200, width: 300, height: 50)) | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| view.backgroundColor = .white |