Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

Dbank daisukenagata

:octocat:
Focusing
View GitHub Profile
View gist:fd31ca57b69a68a899b686110ef869c8
import SwiftUI
final class ViewModel: ObservableObject {
@Published var spIndex = [""]
}
struct ContentView: View {
@ObservedObject var viewModel = ViewModel()
init() {
View gist:3659f5ba5e984d77f43ea4d5e99f6757
import SwiftUI
import Combine
struct LanguageResponse: Decodable {
var statusCode: Int
var body: String
}
struct ContentView: View {
View gist:91d78147e3df42b342d0b33a2ea91fde
import SwiftUI
import AVFoundation
struct ContentView: View {
var body: some View {
RepresentableViewController()
}
}
struct ContentView_Previews: PreviewProvider {
View gist:a4c09e9e87dbcb7b27a9c98b8166e787
import SwiftUI
struct ContentView: View {
var body: some View {
RepresentableViewController(view: HelloWorldColorView())
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
View gist:2224a2ad7ced15508c587c992abee9da
let array = [1, 2, 3, 4, 5]
let total = array.map { $0 }.reduce(.zero, +)
let average = array.map { $0 }.reduce(.zero, +)/array.count
print(total)
print(average)
View gist:1cfcbafeddbf8a43ccdbe3e0075da5e8
let dic = [Dictionary<String, String>.Element]() // Not Syntactic Sugar
let dic = [(key: "", value: "")] // Syntactic Sugar
View gist:dff1f388815f1ebe90b07ce38d717689
let id = ["111": 111, "222": 222, "333": 333, "444": 444, "555": 555]
let thisissorted = id.sorted { (l, r) -> Bool in
return l.value < r.value ? false : true
}
print(thisissorted)
View gist:c6af55ae7896e8198492b0c0d9168396
import SwiftUI
struct ContentView: View {
@ObservedObject var bind = STBind()
init() {
bind.st = "111"
}
View gist:e458e5997a90a16a0f2e8433fbfac7e8
let numArray:[Int?] = [60, 70, 90, nil, 90, 0, 80, 80, 0, 80]
check()
func check() {
for (i, v) in numArray.enumerated() {
if ((numArray.firstIndex(where: { _ in 0 != v && v != nil })) != nil) {
print("インデックス: \(i)")
}
}
}
View gist:9d04890c64ed32d9ba6e81ea39261fa3
import SwiftUI
struct ContentView: View {
@State private var hovering = false
var body: some View {
Button(action: {
self.hovering.toggle()
}) {