2021-01-01から1年間の記事一覧
@State var form: Form = .none { didSet(oldValue) {} willSet(newValue) {} }
enum Mode { case none case alert case success case retry } @Binding var mode: Mode init(_ mode: Binding< Mode > = .constant(.none)) { self.mode = mode }
xCodeでやる方知っている人は教えて欲しい。Viewを拡張して利用すれば便利に使える。 extension View { func ipad_landscape_disp() -> some View { return self.previewLayout(.fixed(width: 1060, height: 810)) } }
xCodeでやる方知っている人は教えて欲しい。Viewを拡張して利用すれば便利に使える。 extension View { func ipad_landscape_disp() -> some View { return self.previewLayout(.fixed(width: 1060, height: 810)) } }
余白をつけて、3分割する GeometryReader { geometry in VStack { GeometryReader { geometry1 in HStack(spacing: 0) { Text("1").frame(width: geometry1.size.width / 3) .background(Color.green) Text("2").frame(width: geometry1.size.width / 3) .b…
struct Row: View { let title: String @Binding var value: String init(title: String , value: Binding<String> = .constant("未")) { self.title = title _value = value } var body: some View { HStack { Text(title) .font(.caption) Text(value) } } }</string>
import UIKit var data = """ { "A": "A", "B": "B", "C": "C", } """ class A : Codable { var A:String = "A" enum CodingKeys: String, CodingKey { case A = "A" } func encode(to encoder: Encoder) throws { var container = encoder.container(keyedB…
import UIKit enum Country: Int, Codable { case japan = 0 case usa case france } struct Member: Codable { let id: Int let country: Country } let json = """ { "id": 1, "country": 0 } """ let decoded = try JSONDecoder().decode(Member.self, fr…
import UIKit protocol Json : Codable { func json(key: String) -> String! var json:String! { get } } extension Json { func json(key: String) -> String! { let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 encoder.outputForm…
import UIKit protocol Json : Codable { func json(key: String) -> String! var json:String! { get } } extension Json { func json(key: String) -> String! { let encoder = JSONEncoder() encoder.dateEncodingStrategy = .iso8601 encoder.outputForm…
struct User { func decorate(a: String) -> String { return "+++" + a + "+++" } func decorate(a: String, b: String) -> String { let a = self.decorate(a:a) let b = self.decorate(a:b) return a + ":" + b } } let user = User() let str = user.dec…
こんな感じでできるのか。いちいち、変数ごとにprintしてたよ。 var a1 = "Hello, playground" var a2 = "hoge" print(a1, a2)