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 | |
protocol Paper {} | |
class APaper: Paper { | |
var a: String | |
var text: String | |
init(a: String, text: 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
func collectionViewSize(flowLayout: UICollectionViewFlowLayout, numberOfItemsInRow count: Int) -> CGSize { | |
let itemSpacing = flowLayout.minimumInteritemSpacing | |
let leftInset = flowLayout.sectionInset.left | |
let rightInset = flowLayout.sectionInset.right | |
let size = (collectionView.bounds.width - (leftInset + rightInset) - (itemSpacing * CGFloat(count - 1))) / CGFloat(count) | |
return CGSize(width: size, height: size) | |
} |
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 | |
protocol Reusable { } | |
extension UITableViewCell: Reusable { } | |
extension UICollectionViewCell: Reusable { } | |
extension UITableView { | |
func register<T: Reusable>(_ type: T.Type) { |
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 CommonCrypto | |
//Reference : https://stackoverflow.com/questions/55356220/get-string-md5-in-swift-5 | |
extension String { | |
var md5: String { | |
let data = Data(self.utf8) | |
let hash = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> [UInt8] in | |
var hash = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH)) |
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 | |
extension UIViewController { | |
class var rootTabBarController: TabBarController? { | |
guard let keyWindow = UIApplication.shared.keyWindow else { return nil } | |
return keyWindow.rootViewController as? TabBarController | |
} | |
class var topMost: UIViewController? { |
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 | |
extension UIPanGestureRecognizer { | |
enum Direction: String { | |
case up | |
case down | |
case left | |
case right | |
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 class ISImageView: UIImageView { | |
@IBInspectable public var isInteractable: Bool = false { | |
didSet { | |
guard oldValue != isInteractable else { return } | |
if isInteractable { | |
setupGesture() | |
cellForTarget(superview: superview)?.clipsToBounds = false |
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
protocol URLSchemeConvertible { | |
var url: URL? { get } | |
var urlString: String { get } | |
} | |
extension URLSchemeConvertible { | |
var queryItems: [URLQueryItem]? { | |
return URLComponents(string: urlString)?.queryItems | |
} |
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 ObservableType { | |
func postNotification(_ name: Notification.Name) -> Observable<E> { | |
return self.do(onNext: { element in | |
NotificationCenter.default.post(name: name, object: element) | |
}) | |
} | |
} | |
///////// |
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 RxSwift | |
import UIKit | |
extension UIAlertController { | |
struct AlertAction { | |
var title: String? | |
var style: UIAlertAction.Style | |
static func action(title: String?, style: UIAlertAction.Style = .default) -> AlertAction { |
NewerOlder