May 3, 2024, 3:08 p.m. | BC

DEV Community dev.to




SwiftUI



  • Challenge day: Unit Converter


https://www.hackingwithswift.com/100/swiftui/19


I used VStack and HStack with the help of GPT-4.



import SwiftUI

struct ContentView: View {
@State private var f: Double = 68
@State private var c: Double = 0
@FocusState private var isFocusedF
@FocusState private var isFocusedC

func f2c(_ f: Double) -> Double {
Double(String(format: "%.2f", (f-32) * 5 / 9))!
}

func c2f(_ c: Double) -> Double {
Double(String(format:"%.2f", c * 9 / 5 + 32))!
}

var body: some View { …

challenge converter format gpt gpt-4 import learn state string struct swift swiftui view

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US