Skip to content

Instantly share code, notes, and snippets.

import Combine
class Foo {
var blurValuePublisher: AnyPublisher<Float, Never> {
_blurValuePublisher.eraseToAnyPublisher()
}
private var _blurValuePublisher: CurrentValueSubject<Float, Never>
init() {
import Combine
import Foundation
class CombineExampleBase {
@Published var baseValue: Int
init(baseValue: Int) {
self.baseValue = baseValue
}
}
class Curried {
let x: Int
init(x: Int) {
self.x = x
}
func yummy() -> String {
"Curry is \(x)"
}
/// PrintIt.swift
@objcMembers public class PrintIt: NSObject {
func printIt(_ dict: [String : String]) {
print(dict)
}
}
/// ViewController.m
#import <PrintIt-Swift.h>
@steveriggins
steveriggins / gist:b30038513e745579db6115d75d676c4b
Created June 25, 2020 14:07
Xcode Derived Data Exclusion for Backblaze
<excludefname_rule plat="mac" osVers="*" ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/DerivedData/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
# More Info: https://help.backblaze.com/hc/en-us/articles/220973007-Advanced-Topic-Setting-Custom-Exclusions-via-XML
//
// KnobView.swift
//
// Created by Steve Riggins on 6/30/19.
// Copyright © 2019 Steve Riggins. All rights reserved.
//
import SwiftUI
struct KnobView : View {
//
// ContentView.swift
// X
//
// Created by Steve Riggins on 6/29/19.
// Copyright © 2019 Steve Riggins. All rights reserved.
//
import SwiftUI
@steveriggins
steveriggins / gist:10dfd72fe11f698e5c3452cf42ce92b7
Created October 1, 2017 00:04
Using Dictionary with Codable
// Example of encoding and decoding a Swift Dictionary
let d = [
"Casey": 35,
"Erin": 34,
"Declan": 2
]
print("Original Dictionary: \(d)")
let encoder = JSONEncoder()
if let encoded = try? encoder.encode(d)
@steveriggins
steveriggins / gist:e032052e88f02af8767f5eedea07506e
Last active August 23, 2016 15:53
I want to be able to compile out .PathDebug and its usage, but swift has a cow wrapping case .PathDebug with #ifdebug
import UIKit
// This is just an example for figuring out DEBUG
// issues. Strings are used for simplicity of the demo
// In the actual code, structs are returned
// The goal is to have none of the code related to PathDebug
// end up in production code
public enum Paths {
case PathOne
@steveriggins
steveriggins / gist:8486943
Last active January 3, 2016 16:08
Simple label in a viewController's view
- (void)viewDidLoad
{
[super viewDidLoad];
self.listPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
self.listPriceLabel.backgroundColor = [UIColor yellowColor];
[self.view addSubview:self.listPriceLabel];
[self.listPriceLabel sizeToFit];
self.listPriceLabel.text = @"Hello World";