- テスト駆動開発 の感想
()
は感想
- どのようなクラスから始めるかではなくテストから始める
()
は感想import PlaygroundSupport | |
import SwiftUI | |
import Combine | |
class ObservableObject1: ObservableObject { | |
@Published var name: String = "src" | |
} | |
struct ContentView1: View { | |
@ObservedObject private var object = ObservableObject1() |
/*: | |
# EnvironmentValuesはSubViewに伝搬するしカスタムなKeyも指定できる | |
- EnvironmentValuesは特定のKeyに対して値を設定できる | |
- 標準のKey | |
- https://developer.apple.com/documentation/swiftui/environmentvalues | |
- EnvironmentValuesが特定のViewの項目にそのまま紐付いている | |
- 例えば標準のKeyである\.fontはView上のTextのfontと結びついている | |
- Keyの値がView暗黙的にバインディングされている感じ |
import Foundation | |
protocol UseCase where Failure: Error { | |
associatedtype Parameters | |
associatedtype Success | |
associatedtype Failure | |
func callAsFunction(_ parameters: Parameters, completion: ((Result<Success, Failure>) -> ())?) | |
} |
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
textlint: |
//: Playground | |
import Combine | |
let publisherA = (1...4).publisher | |
let publisherB = publisherA.map { $0 * 100 } | |
_ = Publishers.CombineLatest(publisherA, publisherB) | |
.print() | |
.sink(receiveValue: { |
import SwiftUI | |
extension EnvironmentValues { | |
struct AccessTokenKey: EnvironmentKey { | |
static var defaultValue: String? { | |
nil | |
} | |
} | |
var accessToken: String? { |
import UIKit | |
import PhotosUI | |
class ViewController: UIViewController { | |
@IBAction func presentPickerForImagesIncludingLivePhotos(_ sender: Any) { | |
presentPicker(filter: PHPickerFilter.images) | |
} | |
private func presentPicker(filter: PHPickerFilter) { |
import Foundation | |
import MobileCoreServices | |
import CoreImage | |
public struct JPEGConverter { | |
let data: Data | |
let dataUTI: String | |
public init(data: Data, with dataUTI: String) { | |
self.data = data |
XCRUN = /usr/bin/env xcrun --sdk macosx | |
SWIFT_FORMAT_PATHS = <フォーマットしたいパス> | |
format: | |
$(XCRUN) swift run -c release \ | |
swift-format --mode format --recursive --in-place $(SWIFT_FORMAT_PATHS) | |
format-skip-build : | |
$(XCRUN) swift run -c release --skip-build \ | |
swift-format --mode format --recursive --in-place $(SWIFT_FORMAT_PATHS) |