Post

Replies

Boosts

Views

Activity

Reply to Xcode can not preview [AppName].swift (Xcode 11)
Are you still experiencing this problem? I know it's been 3 months already, but I'm just curious You can try downloading the latest beta of Xcode (Xcode 12.2 Beta 2). If that doesn't solve the problem, try building and running the app first, then wait until it finishes building. After the app gets launched in the simulator, close the simulator window and click "resume" on the canvas page.
Oct ’20
Reply to How do I access a view from a different file?
@2012jacky, sure. // //  ContentView.swift //  MinimalisticCalculator // //  Created by Joe Mama on 10/6/20. // import SwiftUI struct ContentView: View { @State private var darkMode = false     var body: some View { ZStack{ if darkMode { Color.black .ignoresSafeArea() } else { } VStack{ KeysView() HStack { Button(action: { self.darkMode.toggle() }) { if darkMode { Image(systemName: "moon.fill") } else { Image(systemName: "moon") } } } } }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
Oct ’20
Reply to ForEach loop keeps giving me an error
@OOPer, thank you so much. I found a fix. ForEach((1...10), id: \.self) { Text("\($showingSheet)") } This doesn't work because showSheet is not in the same struct and also private. After reading your answer, I changed my code to this: ForEach(0..<10) {_ in Text("Hello") } The _ in part is required. If I remove that, I'l get an Contextual type for closure argument list expects 1 argument, which cannot be implicitly ignored error. If I changed (0..<10) to (0...10), I get this error: Cannot convert value of type 'ClosedRange<Int>' to expected argument type 'Range<Int>' Thank you so much :D
Sep ’20
Reply to ForEach loop keeps giving me an error
@OOPer import SwiftUI struct ContentView: View { @State private var showingSheet = false     var body: some View { ZStack{ VStack{ Text("Reference Buddy :D") .font(.title) .fontWeight(.bold) HStack{ Button("Physics") { self.showingSheet.toggle() } .sheet(isPresented: $showingSheet) { physicsPage() } Button("Trigonometry", action: {}) Button("Calculus", action: {}) } HStack{ Button("Pre-calculus", action: {}) Button("Geometry", action: {}) Button("Statistics", action: {}) } HStack{ Button("Chemistry", action: {}) Button("Biology", action: {}) Button("Astronomy", action: {}) } } }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } struct physicsPage: View { @Environment(\.presentationMode) var presentationMode var body: some View { VStack{ Text("Did you know that...") ForEach((1...10), id: \.self) { Text("\($showingSheet)") } Button("Back") { self.presentationMode.wrappedValue.dismiss() } } } }
Sep ’20