Skip to content

Instantly share code, notes, and snippets.

View PaulWoodIII's full-sized avatar

Paul Wood III PaulWoodIII

View GitHub Profile
@PaulWoodIII
PaulWoodIII / Serializable.swift
Last active February 3, 2016 19:26 — forked from anaimi/Serializable.swift
Serialize a Swift object to JSON or Dictionary, with selective properties.
/**
Purpose:
Convert (or Serialize) an object to a JSON String or Dictionary.
Usage:
Use 'Serialize.toJSON' on instances of classes that:
- Inherit from NSObject
- Implement 'Serializable' protocol
- Implement the property 'jsonProperties' and return an array of strings with names of all the properties to be serialized
Inspiration/Alternative:
https://gist.github.com/anaimi/ad336b44d718430195f8
@PaulWoodIII
PaulWoodIII / timezones.swift
Created September 5, 2016 19:15
Get all NSTimeZones and turn it into a usable Dictionary
//: # TimeZones
import Foundation
let tzs = NSTimeZone.knownTimeZoneNames()
var seperated : [String:Array<String>] = [String:[String]]()
func addToSeperated(_ region : String,_ place:String) -> Void {
if let _ = seperated[region] {
//
// TestSomethingCoolTests.m
// TestSomethingCoolTests
//
// Created by Paul Wood on 9/14/16.
// Copyright © 2016 Paul Wood. All rights reserved.
//
#import <XCTest/XCTest.h>
#!/usr/bin/env xcrun swift
import Foundation
print("This is a swift script!")
print("Arguments: \(ProcessInfo.processInfo.arguments)")
@PaulWoodIII
PaulWoodIII / Emoji.swift
Created October 29, 2016 17:24
Emoji as a model object extra bits for full text searching and a string extension "isEmoji"
//
// Emoji.swift
// Tipski
//
// Created by Paul Wood on 10/29/16.
// Copyright © 2016 Paul Wood. All rights reserved.
//
// Assumes you have a file named emojis.json as a resource
// That file can be found here: https://github.com/muan/emoji/blob/gh-pages/javascripts/emojilib/emojis.json
// Thanks so much to the contributors of emojilib!
import XCTest
import Combine
import Entwine
import EntwineTest
class EntwineTestSchedulerExampleTests: XCTestCase {
func testSchedulerInjection() {
let scheduler = TestScheduler(initialClock: 0)
var didSink = false
//: A UIKit based Playground for presenting user interface
import SwiftUI
import UIKit
import PlaygroundSupport
import Combine
class ObservingSource: BindableObject {
var someString: String = ""
var willChange = PassthroughSubject<String,Never>()
@PaulWoodIII
PaulWoodIII / MultipleIdentifiableList-CompilerError.swift
Last active August 3, 2019 23:27
Protocol Associated Types with SwiftUI Identifiable will not work
//: [Previous](@previous)
import Foundation
import SwiftUI
import UIKit
import PlaygroundSupport
// This doesnt work because the protocol has an assoicated Type
// To understand more
// https://chariotsolutions.com/screencast/philly-ete-2019-rob-napier-generic-swift-it-isnt-supposed-to-hurt/
@PaulWoodIII
PaulWoodIII / MultipleIdentifiableList.swift
Last active August 4, 2019 00:18
Wrapper around specialized datatype with SwiftUI Identifiable will work
//: [Previous](@previous)
import SwiftUI
import PlaygroundSupport
protocol Nameable {
var name: String { get }
}
struct Name: Nameable {
@PaulWoodIII
PaulWoodIII / IdentifiableActionSheet.swift
Last active August 3, 2019 21:54
Quick example of Identifiable Action Sheets using SwiftUI, one view may need many different action sheets and this is one implementation to handle that, and even share action sheet logic across your application
//: [Previous](@previous)
import SwiftUI
import UIKit
import PlaygroundSupport
struct IdentifiableActionSheet : View {
@State var displaySheet: SheetTypes? = nil