- Open below directory in Finder with Cmnd + Shift + G
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
// Original article here: https://www.fivestars.blog/code/swiftui-hierarchy-list.html | |
import SwiftUI | |
struct FileItem: Identifiable { | |
let name: String | |
var children: [FileItem]? | |
var id: String { name } |
import UIKit | |
struct Action { | |
let title: String | |
let style: UIAlertAction.Style | |
let action: () -> Void | |
} | |
extension Action { | |
static func `default`(_ title: String, action: @escaping () -> Void) -> [Action] { |
Group { | |
UIViewPreview { | |
let button = FavoriteButton(frame: .zero) | |
return button | |
} | |
UIViewPreview { | |
let button = FavoriteButton(frame: .zero) | |
button.isFavorited = true | |
return button | |
} |
public protocol RichTextEditorDelegate: class { | |
func textDidChange(text: String) | |
func heightDidChange() | |
} | |
fileprivate class WeakScriptMessageHandler: NSObject, WKScriptMessageHandler { | |
weak var delegate: WKScriptMessageHandler? | |
init(delegate: WKScriptMessageHandler) { | |
self.delegate = delegate |
- (UIImage *)dynamicImage | |
{ | |
UITraitCollection *const baseTraitCollection = /* an existing trait collection */; | |
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]]; | |
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]; | |
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]]; | |
__block UIImage *lightImage; | |
[lightTraitCollection performAsCurrentTraitCollection:^{ | |
lightImage = /* draw image */; |
/* | |
ModelBinding<T>: a simple class for binding a Flutter app to a immutable | |
model of type T. | |
This is a complete application. The app shows the state of an instance of | |
MyModel in a button's label, and replaces its MyModel instance when the | |
button is pressed. | |
ModelBinding is an inherited widget that must be created in a context above |
tap "ethereum/ethereum" | |
tap "heroku/brew" | |
tap "homebrew/boneyard" | |
tap "homebrew/bundle" | |
tap "homebrew/cask" | |
tap "homebrew/cask-versions" | |
tap "homebrew/core" | |
tap "paritytech/paritytech" | |
cask "java" | |
brew "ansible" |
import UIKit | |
import Foundation | |
func test(named: String, | |
_ work: (_ assert: @escaping (Bool) -> Void, _ done: @escaping () -> Void) -> Void) { | |
var testPass = true | |
var assertCount = 0 | |
let assert: (Bool) -> Void = { value in | |
assertCount = assertCount + 1 | |
testPass = testPass && value |
{% for type in types.based.JSONAutoRepresentable| %} | |
// sourcery:inline:auto:{{ type.name }}.JSONAutoRepresentable | |
init(_ json: JSON) { | |
{% for variable in type.storedVariables where variable|!annotated:"skip" %} | |
{% elif variable.type.based.JSONAutoRepresentable %} | |
{{ variable.name }} = {{ variable.unwrappedTypeName }}(json["{{ variable.name|camelToSnakeCase }}"]) | |
{% elif variable.isArray %} | |
{{ variable.name }} = json["{{ variable.name|camelToSnakeCase }}"].arrayValue.map({{ variable.typeName.array.elementTypeName.unwrappedTypeName }}.init) | |
{% elif variable.type.kind == "enum" %} | |
{{ variable.name }} = {{ variable.unwrappedTypeName }}(rawValue: json["{{ variable.name|camelToSnakeCase }}"].stringValue) ?? {{ variable.defaultValue }} |