Post

Replies

Boosts

Views

Activity

How do I show the whole month name and not 3 letters?
Hello, How do I show the whole month name and not just 3 letters? import SwiftUI struct ContentView: View {     @State var dateString = ""     var body: some View {         VStack {             Image(systemName: "globe")                 .imageScale(.large)                 .foregroundColor(.accentColor)             Text(dateString)         }         .onAppear{             dateString = Date.now.formatted(.dateTime.month().day().year())         }     } }
1
0
670
Aug ’22
SwiftUI and MapKit error, thread 1
Greetings, in the @main file I keep getting this error, "Thread 1: "-[MTLSimHeap protectionOptions]: unrecognized selector sent to instance 0x600001864d20"" I have no idea what's causing it and how to solve it. Here is the code: import SwiftUI import MapKit struct ContentView: View { @StateObject private var viewModel = ContentViewModel()    var body: some View { ZStack {        Map(coordinateRegion: $viewModel.region, showsUserLocation: true) .accentColor(.blue) .onAppear{                 viewModel.checkIfLocationServicesEnabled()                                      }                      }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } final class ContentViewModel: NSObject, ObservableObject, CLLocationManagerDelegate{          var locationManager: CLLocationManager?          @Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.331516, longitude: -121.891054), span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))          func checkIfLocationServicesEnabled() {         if CLLocationManager.locationServicesEnabled() {             locationManager = CLLocationManager()             locationManager!.delegate = self                      } else {             print("show alert: location is off.")         }     }   private func checkLocationAuthorization() {                guard let locationManager = locationManager else { return }                  switch locationManager.authorizationStatus {                          case .notDetermined:             locationManager.requestWhenInUseAuthorization()                          case .restricted:             print("Your Location is restricted likely due to parental controls.")             case .denied:             print("You denied this app location permission, go to the settings to change it.")             case .authorizedAlways, .authorizedWhenInUse:             region = MKCoordinateRegion(center: locationManager.location!.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))             @unknown default:             break         }     }          func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {         checkLocationAuthorization()     } } The @main file: import SwiftUI @main struct MyApp: App {               var body: some Scene {         WindowGroup {             ContentView()         }     } }
1
0
691
Aug ’22
ForEach and variable
Greetings, can’t increase number of times ForEach is repeated, any solution? import SwiftUI struct ContentView: View {          @State var numberOfTimes: Int = 0          var body: some View {         VStack {             ForEach(1..<numberOfTimes, id: \.self) { i in                  Text("i \(i)")             }              Text("Add one")                 .onTapGesture {                     numberOfTimes = numberOfTimes + 1                 }         }     } }
1
1
437
Aug ’22
Jamie
I keep getting this error,” Cannot convert value of type ‘Currentlydoing.Type’ to expected argument type ‘Currrentlydoing”. When I remove the,”done: Currentlydoing” it gives an error saying,”Missing argument for parameter ‘done’ in call insert done: ,#Currenlydoing# “ but when I insert it it gives the original error. What’s the solution? import SwiftUI struct ContentView: View {    var done: Currentlydoing var body: some View {         VStack { Text(done.sleep ? "Hello":"HI")             }     } } struct MainView: View {     var body: some View {         ContentView()     } } struct Currentlydoing: Identifiable, Codable {     var id: String     var text : String     var work: Bool     var sleep: Bool }
1
0
515
Aug ’22
Purchases
Hello everyone! I’m going to publish my first app, does the credit card you use for purchases link to your Apple ID or it’ Is it separate. If so how can I change it?
Replies
0
Boosts
0
Views
667
Activity
Sep ’22
How do I show the whole month name and not 3 letters?
Hello, How do I show the whole month name and not just 3 letters? import SwiftUI struct ContentView: View {     @State var dateString = ""     var body: some View {         VStack {             Image(systemName: "globe")                 .imageScale(.large)                 .foregroundColor(.accentColor)             Text(dateString)         }         .onAppear{             dateString = Date.now.formatted(.dateTime.month().day().year())         }     } }
Replies
1
Boosts
0
Views
670
Activity
Aug ’22
SwiftUI and MapKit error, thread 1
Greetings, in the @main file I keep getting this error, "Thread 1: "-[MTLSimHeap protectionOptions]: unrecognized selector sent to instance 0x600001864d20"" I have no idea what's causing it and how to solve it. Here is the code: import SwiftUI import MapKit struct ContentView: View { @StateObject private var viewModel = ContentViewModel()    var body: some View { ZStack {        Map(coordinateRegion: $viewModel.region, showsUserLocation: true) .accentColor(.blue) .onAppear{                 viewModel.checkIfLocationServicesEnabled()                                      }                      }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } final class ContentViewModel: NSObject, ObservableObject, CLLocationManagerDelegate{          var locationManager: CLLocationManager?          @Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.331516, longitude: -121.891054), span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))          func checkIfLocationServicesEnabled() {         if CLLocationManager.locationServicesEnabled() {             locationManager = CLLocationManager()             locationManager!.delegate = self                      } else {             print("show alert: location is off.")         }     }   private func checkLocationAuthorization() {                guard let locationManager = locationManager else { return }                  switch locationManager.authorizationStatus {                          case .notDetermined:             locationManager.requestWhenInUseAuthorization()                          case .restricted:             print("Your Location is restricted likely due to parental controls.")             case .denied:             print("You denied this app location permission, go to the settings to change it.")             case .authorizedAlways, .authorizedWhenInUse:             region = MKCoordinateRegion(center: locationManager.location!.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))             @unknown default:             break         }     }          func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {         checkLocationAuthorization()     } } The @main file: import SwiftUI @main struct MyApp: App {               var body: some Scene {         WindowGroup {             ContentView()         }     } }
Replies
1
Boosts
0
Views
691
Activity
Aug ’22
ForEach and variable
Greetings, can’t increase number of times ForEach is repeated, any solution? import SwiftUI struct ContentView: View {          @State var numberOfTimes: Int = 0          var body: some View {         VStack {             ForEach(1..<numberOfTimes, id: \.self) { i in                  Text("i \(i)")             }              Text("Add one")                 .onTapGesture {                     numberOfTimes = numberOfTimes + 1                 }         }     } }
Replies
1
Boosts
1
Views
437
Activity
Aug ’22
Jamie
I keep getting this error,” Cannot convert value of type ‘Currentlydoing.Type’ to expected argument type ‘Currrentlydoing”. When I remove the,”done: Currentlydoing” it gives an error saying,”Missing argument for parameter ‘done’ in call insert done: ,#Currenlydoing# “ but when I insert it it gives the original error. What’s the solution? import SwiftUI struct ContentView: View {    var done: Currentlydoing var body: some View {         VStack { Text(done.sleep ? "Hello":"HI")             }     } } struct MainView: View {     var body: some View {         ContentView()     } } struct Currentlydoing: Identifiable, Codable {     var id: String     var text : String     var work: Bool     var sleep: Bool }
Replies
1
Boosts
0
Views
515
Activity
Aug ’22