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 final class Obfuscator { | |
/// The salt used to obfuscate and reveal the string. | |
static let salt: String = "\(String(describing: Obfuscator.self))\(String(describing: NSObject.self))" | |
/** | |
This method obfuscates the string passed in using the salt | |
that was used when the Obfuscator was initialized. | |
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 | |
public protocol UICollectionViewCellIdentifiable: UICollectionViewCell { | |
static var identifier: String { get } | |
} | |
public extension UICollectionViewCellIdentifiable where Self: UICollectionViewCell { | |
static var identifier: String { | |
return String(describing: 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
import UIKit | |
public protocol UITableViewHeaderFooterViewIdentifiable: UITableViewHeaderFooterView { | |
static var identifier: String { get } | |
} | |
public extension UITableViewHeaderFooterViewIdentifiable where Self: UITableViewHeaderFooterView { | |
static var identifier: String { | |
return String(describing: 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
import Foundation | |
public extension Bundle { | |
var releaseVersionNumber: String? { | |
return infoDictionary?["CFBundleShortVersionString"] as? String | |
} | |
var buildVersionNumber: String? { | |
return infoDictionary?["CFBundleVersion"] as? String | |
} | |
} |
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 UIApplication { | |
class func tryURL(_ urls: [String]) { | |
let application = UIApplication.shared | |
urls.forEach { urlString in | |
guard let url = URL(string: urlString) else { | |
Logger.error?.message("Cannot make url from: \(urlString)") | |
return | |
} |
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 | |
public extension UIToolbar { | |
static func toolbarDone(text: String = "Done", target: Any?, action: Selector?) -> UIToolbar { | |
let toolbar = UIToolbar() | |
toolbar.sizeToFit() | |
let doneButton = UIBarButtonItem(title: text, style: .plain, target: target, action: action) | |
toolbar.setItems([doneButton], animated: false) | |
return toolbar | |
} |
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 String { | |
func slice(from firstString: String, to lastString: String) -> String? { | |
return (range(of: firstString)?.upperBound).flatMap { substringFrom in | |
(range(of: lastString, range: substringFrom..<endIndex)?.lowerBound).map { substringTo in | |
String(self[substringFrom..<substringTo]) | |
} | |
} | |
} | |
} |
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 | |
public protocol EnterForegroundObservable: AnyObject { | |
var applicationWillEnterForegroundObservation: Any? { get set } | |
typealias ForegroundBackgroundObservationCompletionHandler = () -> Void | |
func applicationWillEnterForegroundObservation(completion: ForegroundBackgroundObservationCompletionHandler?) | |
} | |
public extension EnterForegroundObservable { | |
func applicationWillEnterForegroundObservation(completion: ForegroundBackgroundObservationCompletionHandler?) { |
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 WebKit | |
open class ProgressObservableWebViewController: UIViewController, WKWebViewProgressObservable { | |
@IBOutlet weak public var webView: WKWebView! | |
public var webViewProgressObservation: Any? | |
private let progressView: UIProgressView = { | |
let view = UIProgressView(progressViewStyle: .default) |