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 CommonCrypto | |
// MARK: AES128 暗号、復号化 | |
public extension String { | |
func aesEncrypt(key: String, iv: String) -> String? { | |
guard | |
let data = self.data(using: .utf8), | |
let key = key.data(using: .utf8), | |
let iv = iv.data(using: .utf8), |
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 | |
extension View { | |
/// Proposes a percentage of its received proposed size to `self`. | |
/// | |
/// This modifier multiplies the proposed size it receives from its parent | |
/// with the given factors for width and height. | |
/// | |
/// If the parent proposes `nil` or `.infinity` to us in any dimension, | |
/// we’ll forward these values to our child view unchanged. |
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
// | |
// AdvancedToolbarWindow.swift | |
// | |
// Created by Stephan Casas on 3/17/23. | |
// | |
import SwiftUI; | |
import AppKit; | |
class AdvancedToolbarWindow<MainContent: View, TitleToolbarContent: View>: NSWindow, NSToolbarDelegate { |
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
// | |
// ContentView.swift | |
// AppleMusicLyricsPlayer | |
// | |
// Created by Magesh Sridhar on 2/5/23. | |
// | |
import SwiftUI | |
import AVKit |
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 | |
protocol TitleProvider { | |
var title: String { get } | |
} | |
extension ColorScheme { | |
var dual: ColorScheme { | |
switch self { | |
case .light: return .dark |
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
// | |
// NSPersistentContainer+extension.swift | |
// CDMoveDemo | |
// | |
// Created by Tom Harrington on 5/12/20. | |
// Copyright © 2020 Atomic Bird LLC. All rights reserved. | |
// | |
import Foundation | |
import CoreData |
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 xcrun swift -i | |
import Foundation | |
enum Result<T, E> { | |
/* | |
We can't use this at the moment due to a LLVM Error: | |
error: unimplemented IR generation feature non-fixed multi-payload enum layout | |
LLVM ERROR: unimplemented IRGen feature! non-fixed multi-payload enum layout |
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
(headers) { | |
header { | |
-Server | |
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" | |
X-XSS-Protection "1; mode=block" | |
X-Permitted-Cross-Domain-Policies "none" | |
X-Content-Type-Options "nosniff" | |
X-Frame-Options "SAMEORIGIN" | |
X-Robots-Tag "nine" | |
Permissions-Policy interest-cohort=() |
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
class URLProtocolMock: URLProtocol { | |
/// Dictionary maps URLs to tuples of error, data, and response | |
static var mockURLs = [URL?: (error: Error?, data: Data?, response: HTTPURLResponse?)]() | |
override class func canInit(with request: URLRequest) -> Bool { | |
// Handle all types of requests | |
return true | |
} | |
override class func canonicalRequest(for request: URLRequest) -> URLRequest { |