Skip to content

Instantly share code, notes, and snippets.

View artemnovichkov's full-sized avatar
👨‍💻
Write code. Blow minds.

Artem Novichkov artemnovichkov

👨‍💻
Write code. Blow minds.
View GitHub Profile
@artemnovichkov
artemnovichkov / UserDefaults+InterfaceStyle.swift
Last active December 25, 2022 12:30
Saving UIUserInterfaceStyle to UserDefaults
public extension UserDefaults {
var overridedUserInterfaceStyle: UIUserInterfaceStyle {
get {
UIUserInterfaceStyle(rawValue: integer(forKey: #function)) ?? .unspecified
}
set {
set(newValue.rawValue, forKey: #function)
}
}
@artemnovichkov
artemnovichkov / UITraitEnvironment.swift
Created December 16, 2019 04:14
Updating layer colors with new trait collection
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
traitCollection.hasDifferentColorAppearance(comparedTo: traitCollection) {
layer.backgroundColor = UIColor.layer.cgColor
}
}
@artemnovichkov
artemnovichkov / UIApplication+UserInterfaceStyle.swift
Last active December 11, 2020 22:49
Updating application with new user interface style
import UIKit
public extension UIApplication {
func override(_ userInterfaceStyle: UIUserInterfaceStyle) {
if supportsMultipleScenes {
for connectedScene in connectedScenes {
if let scene = connectedScene as? UIWindowScene {
for window in scene.windows {
window.overrideUserInterfaceStyle = userInterfaceStyle
@artemnovichkov
artemnovichkov / JSONDecoder+Result.swift
Created March 12, 2020 12:29
JSONDecoder + Result
import Foundation
public extension JSONDecoder {
func decode<T>(_ type: T.Type, from data: Data) -> Result<T, Error> where T: Decodable {
do {
let decodedData: T = try decode(T.self, from: data)
return .success(decodedData)
}
catch {
@artemnovichkov
artemnovichkov / image.jpg
Last active November 6, 2025 00:15
👨‍💻 Random Xcode shortcut every day
image.jpg
@artemnovichkov
artemnovichkov / rings.png
Last active November 11, 2023 16:13
Activity summary
rings.png
@artemnovichkov
artemnovichkov / image.jpg
Last active August 19, 2025 00:34
⌨️ Monkeytype Personal Bests
image.jpg