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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
A collection of all of the various options and styles available to you if you'd like to format data into string on iOS 15.
See every option in detail at fuckingformatstyle.com or goshdarnformatstyle.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
// MARK: - Setup | |
let twosdayDateComponents = DateComponents( | |
year: 2022, | |
month: 2, | |
day: 22, | |
hour: 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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' |
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: