Post

Replies

Boosts

Views

Activity

Type UITextField has no member padding
Expected to connect to ContentView which is my View module with the code below. What can I get rid of, add, or edit? import Foundation import SwiftUI struct ContentView: View { @State private var searchQuery = "" @State private var searchResult: SearchResult? var body: some View { VStack { UITextField .padding() .background(Color.gray.opacity(0.2)) .cornerRadius(10) .padding() Button(action: { Task { do { let resultData = try await queryAPI(for: searchQuery) searchResult = try JSONDecoder().decode(SearchResult.self, from: resultData) } catch { print("Error: \(error)") } } }) { Text("Search") .padding() .foregroundColor(.white) .background(Color.blue) .cornerRadius(10) } if let result = searchResult { Text(result.answer) .padding() } } } func queryAPI(for query: String) async throws -> Data { let url = URL(string: "https://example.com/search?q=\(query)")! let (data, _) = try await URLSession.shared.data(from: url) return data } } struct SearchResult: Codable { let query: String let answer: String }
2
0
1.1k
Apr ’23
Type UITextField has no member padding
Expected to connect to ContentView which is my View module with the code below. What can I get rid of, add, or edit? import Foundation import SwiftUI struct ContentView: View { @State private var searchQuery = "" @State private var searchResult: SearchResult? var body: some View { VStack { UITextField .padding() .background(Color.gray.opacity(0.2)) .cornerRadius(10) .padding() Button(action: { Task { do { let resultData = try await queryAPI(for: searchQuery) searchResult = try JSONDecoder().decode(SearchResult.self, from: resultData) } catch { print("Error: \(error)") } } }) { Text("Search") .padding() .foregroundColor(.white) .background(Color.blue) .cornerRadius(10) } if let result = searchResult { Text(result.answer) .padding() } } } func queryAPI(for query: String) async throws -> Data { let url = URL(string: "https://example.com/search?q=\(query)")! let (data, _) = try await URLSession.shared.data(from: url) return data } } struct SearchResult: Codable { let query: String let answer: String }
Replies
2
Boosts
0
Views
1.1k
Activity
Apr ’23
Having trouble importing streamlit and transposing Python code into Swift
Im having trouble deploying my Streamlit app onto Xcode locally. Its imported onto my Terminal. How do I transpose this Python code into Swift so that I can successfully run my build? Looks like my package was imported successfully, my syntax is still off.
Replies
0
Boosts
0
Views
638
Activity
Sep ’22