Skip to content

Instantly share code, notes, and snippets.

View brettohland's full-sized avatar

brett ohland brettohland

View GitHub Profile

Keybase proof

I hereby claim:

  • I am brettohland on github.
  • I am bretto (https://keybase.io/bretto) on keybase.
  • I have a public key whose fingerprint is 424B 5733 C07A DD48 3D7B 8147 1F6B 0BDD 87F4 51F2

To claim this, I am signing this object:

#! /usr/bin/env ruby
require 'fileutils'
require 'pathname'
#Remove the \n character at the end of the path returned
root = %x(git rev-parse --show-toplevel).chomp
root_path = Pathname.new(root)
podfile = root + '/Podfile.lock'
@brettohland
brettohland / dates.swift
Last active March 12, 2022 14:49
Date.FormatStyle Examples and Usage
import SwiftUI
import UIKit
// MARK: - Setup
let twosdayDateComponents = DateComponents(
year: 2022,
month: 2,
day: 22,
hour: 2,
struct ToYen: FormatStyle {
typealias FormatInput = Int
typealias FormatOutput = String
func format(_ value: Int) -> String {
Decimal(value * 100).formatted(.currency(code: "jpy"))
}
}
extension FormatStyle where Self == ToYen {
@brettohland
brettohland / 1.0 FormatStyle in Excruciating Detail.md
Last active July 23, 2024 12:12
FormatStyle in Excruciating Detail
import Foundation
// MARK: - URL
// https://developer.apple.com/documentation/foundation/formatstyle/4013379-url
let appleURL = URL(string: "https://apple.com")!
appleURL.formatted() // "https://apple.com"
appleURL.formatted(.url) // "https://apple.com"
appleURL.formatted(.url.locale(Locale(identifier: "fr_FR"))) // "https://apple.com"
@brettohland
brettohland / 1.0 README.md
Last active September 23, 2024 05:50
ParseableFormatStyle Examples
@brettohland
brettohland / 1.README.md
Last active October 23, 2023 20:47
ISBN example with FormatStyle, AttributedStringFormatStyle, ParseableFormatStyle conformance.

Supporting FormatStyle & ParseableFormatStyle To Your Custom Types

A full example of adding String and AttributedString output to our custom types, as well as adding the ability to parse String values into your custom type.

Read the blog post

See the Xcode Playground

ko-fi