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
// Presenter | |
typealias SomeViewModel = String // this is just a placeholder for your view model type | |
protocol SomeView { | |
func showSomething(viewModel: SomeViewModel) | |
} | |
protocol SomeViewOutput { | |
func onUserAction() |
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 CellController { | |
func getCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell | |
} | |
struct TextItemModel { | |
let title: 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 UIKit | |
struct CollectionItemModel { | |
let title: String? | |
let image: UIImage? | |
} | |
struct CellController { | |
var model: CollectionItemModel | |
func getCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { |
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 | |
struct CollectionItemModel { | |
let title: String? | |
let image: UIImage? | |
} | |
/// First set `model` and then present on screen. | |
final class MyCollectionViewController: UICollectionViewController { | |
var models: [CollectionItemModel]? |
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 XCTest | |
import Combine | |
import RealmSwift | |
class RealmMultiThreadingStaleDataTests: XCTestCase { | |
private var cancellables: Set<AnyCancellable>! | |
override func setUpWithError() throws { | |
super.setUp() | |
cancellables = [] |
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
autoload -U colors && colors | |
## rbenv | |
eval "$(rbenv init - zsh)" | |
## git | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:*' enable git svn | |
zstyle ':vcs_info:git*' formats "%r/%S%{$fg[grey]%} %{$fg[blue]%}%b%{$reset_color%} (%a) %m%u%c%{$reset_color%} " | |
precmd() { |
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 UIView { | |
static func withoutConstraints() -> Self { | |
let instance = self.init() | |
instance.translatesAutoresizingMaskIntoConstraints = false | |
return instance | |
} | |
func addSubviews(_ views: UIView...) { | |
for view in views { | |
addSubview(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
/// Inspired by | |
/// http://blog.benjamin-encz.de/post/main-queue-vs-main-thread/ | |
/// and https://stackoverflow.com/a/60348601 | |
/// Associates a predefined key/value pair with the main queue and later uses the presence of it | |
/// to determine whether the current queue is the main queue. | |
extension DispatchQueue { | |
private static let mainQueueCheckKey: DispatchSpecificKey<String> = { | |
let mainQueueCheckKey = DispatchSpecificKey<String>() | |
DispatchQueue.main.setSpecific(key: mainQueueCheckKey, value: mainQueueCheckValue) | |
return mainQueueCheckKey |
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 FileManager { | |
func isDirectory(at url: URL) -> Bool { | |
var isDirectory: ObjCBool = false | |
guard FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory) else { | |
return false | |
} | |
return isDirectory.boolValue | |
} | |
} |
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
typealias AlertActionStyle = UIAlertAction.Style | |
extension UIAlertController { | |
static func create( | |
style: UIAlertController.Style, | |
title: String?, | |
message: String?, | |
actions: [AlertAction] = [], | |
onDismiss: VoidHandler? = nil | |
) -> UIAlertController { |
NewerOlder