Skip to content

Instantly share code, notes, and snippets.

View sgl0v's full-sized avatar

Max sgl0v

View GitHub Profile
@sgl0v
sgl0v / Breakpoints_v2.xcbkptlist
Created January 4, 2016 10:03 — forked from Ashton-W/Breakpoints_v2.xcbkptlist
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@sgl0v
sgl0v / create_framework.sh
Created October 10, 2017 15:44 — forked from syshen/gist:c24d127e1adc2783e0e7
Universal framework
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=false
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
@sgl0v
sgl0v / CoreDataController.swift
Created November 9, 2017 21:59 — forked from kharrison/CoreDataController.swift
Swift wrapper for NSPersistentContainer - Easy Core Data Setup with iOS 10
//
// CoreDataController.swift
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@sgl0v
sgl0v / NibLoadable.swift
Created September 5, 2018 09:32
NibLoadable protocol
import UIKit
protocol NibLoadable where Self: UIView {
static func viewFromNib() -> Self
}
extension NibLoadable {
static func viewFromNib() -> Self {
let nibName = String(describing: self)
guard let view = Bundle.main.loadNibNamed(nibName, owner: nil, options: nil)?.first as? Self else {
@sgl0v
sgl0v / atomic.swift
Created September 18, 2019 15:08
Atomic property wrapper
@propertyWrapper
struct Atomic<Value> {
private var value: Value
private let lock = NSLock()
init(wrappedValue value: Value) {
self.value = value
}
@sgl0v
sgl0v / Theme.swift
Created October 6, 2019 15:24
Backward compatible Dark Mode on iOS - Theme.swift
struct Theme {
enum `Type` {
case light
case dark
}
let type: Type
let colors: ColorPalette
}
@sgl0v
sgl0v / Themes.swift
Created October 6, 2019 15:26
Backward compatible Dark Mode on iOS - Themes.swift
extension Theme {
static let light = Theme(type: .light, colors: .light)
static let dark = Theme(type: .dark, colors: .dark)
}
@sgl0v
sgl0v / Themeable.swift
Created October 6, 2019 15:27
Backward compatible Dark Mode on iOS - Themeable.swift
protocol Themeable: class {
func apply(theme: Theme)
}
@sgl0v
sgl0v / ThemeProvider.swift
Created October 6, 2019 15:28
Backward compatible Dark Mode on iOS - ThemeProvider.swift
class ThemeProvider {
static let shared = ThemeProvider()
var theme: Theme {
didSet {
UserDefaults.standard.set(theme == .dark, forKey: "isDark")
notifyObservers()
}
}
private var observers: NSHashTable<AnyObject> = NSHashTable.weakObjects()
@sgl0v
sgl0v / MoviesTableViewController.swift
Created October 6, 2019 15:30
Backward compatible Dark Mode on iOS - MoviesTableViewController.swift
class MoviesTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
themeProvider.register(observer: self)
}
}
extension MoviesTableViewController: Themeable {
func apply(theme: Theme) {