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 | |
public extension DispatchQueue { | |
/** | |
- parameters: | |
- target: Object used as the sentinel for de-duplication. | |
- delay: The time window for de-duplication to occur | |
- work: The work item to be invoked on the queue. | |
Performs work only once for the given target, given the time window. The last added work closure | |
is the work that will finally execute. |
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
// A general hack to prevent Lottie animations from stopping playing after pushing/popping/presenting/dismissing. | |
// Usage: LottieFinder.setupLottieFinder() | |
import UIKit | |
import Lottie | |
class LottieFinder { | |
static private var operationQueue = OperationQueue() | |
static private var operations: [Operation] = [] | |
static func setupLottieFinder() { |
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
// A hack that modifies the values for UIFont read-only properties ascender and descender. | |
// Usage: UIFont.manipulateFont() | |
extension UIFont { | |
static func manipulateFont() { | |
swizzleFont() | |
} | |
static func swizzleFont() { |
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
public extension UIView { | |
func fader( | |
duration: CGFloat, | |
delay: CGFloat = 0, | |
fromValue: CGFloat = 0, | |
toValue: CGFloat = 1, | |
curve: UIView.AnimationCurve = .easeOut, | |
completion: (() -> Void)? = nil | |
) { | |
alpha = fromValue |
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
public extension UIView { | |
class var identifier: String { | |
String(describing: self) | |
} | |
} | |
public extension UITableView { | |
func registerNib(_ type: UITableViewCell.Type, bundle: Bundle) { | |
register( | |
UINib(nibName: type.identifier, bundle: bundle), |
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
// usage -> let viewController: ACustomViewController = UIApplication.getViewController() | |
public extension UIApplication { | |
class func getViewController<T: UIViewController>( | |
inScene named: String? = nil, | |
rootViewController: Bool = true | |
) -> T { | |
let controllerName = String(describing: T.self) | |
let storyboardName = named ?? substringStoryboardName(withViewControllerName: controllerName) | |
if rootViewController, | |
let viewController = UIStoryboard( |
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
// An extension to access safely to items in an array. | |
// usage: | |
// let anArray: [Item] = [......] | |
// let item = anArray[safe: 5] | |
public extension Collection { | |
subscript(safe index: Index) -> Element? { | |
indices.contains(index) ? self[index] : nil | |
} | |
} |
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
// please don't forget to add the custom class for your UIView on the interface builder. | |
public extension UIView { | |
static func initFromNib() -> Self { | |
guard let view = UINib(nibName: String(describing: self), bundle: nil) | |
.instantiate(withOwner: nil, options: nil).first as? Self else { | |
fatalError("Could not init view") | |
} | |
return view | |
} | |
} |
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
// | |
// YOOrderedDictionary.swift | |
// | |
// | |
// Created by okan.yucel on 12.04.2022. | |
// | |
import Foundation | |
class YOOrderedDictionary<Key: Hashable, Value> { | |