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
| // | |
| // FreeFunctions.swift | |
| // IconJob | |
| // | |
| // Created by andrey.antropov on 08.09.2020. | |
| // Copyright © 2020 br. All rights reserved. | |
| // | |
| import Foundation |
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
| @propertyWrapper public struct UserDefault<T> { | |
| public let key: String | |
| public let defaultValue: T | |
| private let container: UserDefaults | |
| public init(key: String, defaultValue: T, container: UserDefaults) { | |
| self.key = key | |
| self.defaultValue = defaultValue | |
| self.container = container |
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 CombineAsyncStream<Upstream: Publisher>: AsyncSequence { | |
| typealias Element = Upstream.Output | |
| typealias AsyncIterator = CombineAsyncStream<Upstream> | |
| func makeAsyncIterator() -> Self { | |
| return self | |
| } | |
| private let stream: | |
| AsyncThrowingStream<Upstream.Output, Error> |
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
| // | |
| // VKLoginWebView.swift | |
| // SwiftUI-Course | |
| // | |
| // Created by andrey.antropov on 14.10.2021. | |
| // | |
| import SwiftUI | |
| import WebKit |
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
| @IBAction func actionButton(_ sender: UIButton) { | |
| if state == 0 { | |
| state = 1 | |
| Timer.publish(every: TimeInterval(0.2), on: RunLoop.main, in: .default) | |
| .autoconnect() | |
| .sink(receiveValue: { [weak self] text in | |
| self?.button1.text = self!.emoji.emojiArray.randomElement() | |
| self?.button2.text = self!.emoji.emojiArray.randomElement() |
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 Combine | |
| import ObjectiveC | |
| import UIKit | |
| private var eventSubjectKey = "viewcontroller_lifecycle_subject" | |
| private var swizzlingPerformed = false | |
| private final class LifecycleSubjectBag: NSObject { | |
| let viewDidLoadSubject = PassthroughSubject<Void, Never>() | |
| let viewWillAppearSubject = PassthroughSubject<Bool, Never>() |
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 swizzleReplacingCharacters() { | |
| let originalMethod = class_getInstanceMethod( | |
| NSString.self, #selector(NSString.replacingCharacters(in:with:))) | |
| let swizzledMethod = class_getInstanceMethod( | |
| NSString.self, #selector(NSString.swizzledReplacingCharacters(in:with:))) | |
| guard let original = originalMethod, let swizzled = swizzledMethod else { | |
| return | |
| } |
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
| var keyboardHeight: CGFloat { | |
| let windows = UIApplication.shared.windows | |
| guard let keyboardWindowClass = NSClassFromString("UIRemoteKeyboardWindow"), | |
| let keyboardWindow = windows.first(where: { $0.isKind(of: keyboardWindowClass) }), | |
| let rootViewController = keyboardWindow.rootViewController, | |
| let keyboardViewClass = NSClassFromString("UIInputSetHostView"), | |
| let keyboardView = rootViewController.view.subviews.first(where: { $0.isKind(of: keyboardViewClass) }) else { return 0 } | |
| return keyboardView.frame.height |
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 Reactive where Base: UIViewController { | |
| var viewWillAppear: Observable<Bool> { | |
| return base.rx.methodInvoked(#selector(UIViewController.viewWillAppear(_:))) | |
| .map { $0[0] as! Bool } | |
| } | |
| } |
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 MyClass { | |
| @Logged(formatString: "HH:mm dd.MM.yyyy") var myProperty = 0 | |
| init() { | |
| print(type(of: _myProperty)) | |
| print(type(of: $myProperty)) | |
| print(type(of: myProperty)) | |
| } | |
| } |
NewerOlder