Post

Replies

Boosts

Views

Activity

Fatal Error in ModelData at line 43
Failed to decode landmarksData.json from bundle because it appears to be invalid JSON. Full disclosure - Im extremely new to this and am playing around with the swift tutorials to see what it can do and see if I could build an app. Any advice is appreciated. I added a few locations to the SwiftUI Tutorial for Lanmarks and this is what happened. I have checked that JSON file and all commas are in the correct place everything is correct but im getting this error. Not sure what im doing incorrectly. Can anyone give me assistance on how to fix this. I can only preview favorite button, circle image and map. Everything else appears as Fatal Error in ModelData.
4
0
2.8k
Aug ’22
Invalid JSON File
So I keep getting a message about Fatal error: Failed to decode Data.json from bundle because it appears to be invalid JSON. What makes files invalid? How can i find out what is exactly invalid and how do i read any debugging. I can't seem to understand the debugging. This is an example of what is in my JSON file. Im not sure where I'm going wrong, im also not even sure what im reading or what i should be looking for. the data in the json file i added is not what's put in i removed the information for the post.
5
0
1.8k
Aug ’22
Adding MapMarkers and adding Filters to Landmarks SwiftUI Tutorial
Hello Everyone, I am looking for some guidance on how to add MapMarkers and Filters to the Landmarks swiftUI tutorial. https://developer.apple.com/tutorials/swiftui/composing-complex-interfaces Would i put the code for the MapMarker in the MapView or create a new file and then add it to MapView? Im confused on how i can get a marker on the map. Also is there a way to create a map where i can just see the Landmarks closest to me? such as on the bottom click map then see the world with markers of all the landmarks? Im trying to search online but i can't seam to figure out what things are called and how to attempt to do them. BOTTOM of App Example template of what i want to add MAP View | Filter View | List View | Directions | Favorites I also wanted to know how to add filters like a filter page that can filter to find a landmark with lets say "paid parking, water views, high traffic area and be able to check all these options and then one or others pop up that meet those filters that were specifically chosen. would i have to edit the JSON file? Does anyone know what that is called Filter (What i want the filter page to look like) parking x --Paid o--free o--street Views o--forest o--dunes x--water Traffic o--low traffic o--moderate traffic x--high traffic Experience o--beginner o--intermediate o--expert
1
0
710
Aug ’22
Having issues with "Form" and either putting it with VStack or HStack
Im trying to add a rate button as well as a review section in the landmarks swift ui tutorial but when i put the "RatingForm" into the Landmark detail page it shows in a tiny section that i separately have to scroll. Please note im extremely new and am learning any assistance is appreciated. The images show what it looks like i can put the code in to LandmarkDetail: import SwiftUI struct LandmarkDetail: View {     @EnvironmentObject var landmarksVM: LandmarksViewModel     var landmark: Landmark          var landmarkIndex: Int{        landmarksVM.landmarks.firstIndex(where:{ $0.id == landmark.id})!     }//var landmarkIndex          @Binding var rating: Int     @State private var review: String = ""          var body: some View {         ScrollView{             MapView(coordinate: landmark.locationCoordinate)                 .frame(height: 300)                 .ignoresSafeArea(edges: .top)                          CircleImage(image: landmark.image)                 .offset(y:-130)                 .padding(.bottom, -130)                                   VStack (alignment: .leading) {             HStack{                 Text(landmark.name)                     .font(.title)                     .foregroundColor(.green)             FavoriteButton(isSet:                             $landmarksVM.landmarks[landmarkIndex].isFavorite)             }//Hstack             HStack {                 Text (landmark.city)                     .foregroundColor(.blue)                 Spacer()                 Text(landmark.state)                 }//Hstack             .font(.subheadline)             .foregroundColor(.secondary)                                       Divider()                          Text("About (landmark.name)")                 .font(.title3)             Text(landmark.description)                          Divider()             ---->           HStack {                     TextEditor(text: $review)                     RatingForm(rating: $rating)             Spacer()                                      }//hstack             //VStack         }//ScrollView         .padding(.all)                      .navigationTitle(landmark.name)         .navigationBarTitleDisplayMode(.inline)         }//body     } }//view     struct LandmarkDetail_Previews: PreviewProvider {     static var previews: some View {         LandmarkDetail(playground: LandmarksViewModel().landmarks[0], rating: .constant(4))               }//var preview }//previewprovider
2
0
829
Sep ’22
Filter List for Landmarks SwiftUI
Im trying to filter rows in the list that match what im looking for, I have added a filter form that toggles the following: parking x --Paid (true) o--free (false) o--street (false) Views o--forest (false) o--dunes (false) x--water (true) Traffic o--low traffic (false) o--moderate traffic (false) x--high traffic (true) Experience x--beginner (true) o--intermediate (false) o--expert (false) My goal is to have a filter that connects to some sort of list that ultimately returns the true options that specifically matches. Im extremely new and this is the code i copied from the tutorial for Landmarks List, but im trying to edit it. Sorry if its all over the place im new to coding. below is a link to the tutorial: https://developer.apple.com/tutorials/swiftui/composing-complex-interfaces struct FilterList: View {     var landmark: Landmark     @EnvironmentObject var landmarksVM: LandmarksViewModel     @State private var showpaidOnly = false     @State private var showfreeOnly = false     @State private var showstreetOnly = false     @State private var showforestOnly = false     @State private var showdunesOnly = false     @State private var showwaterOnly = false     @State private var showlowtrafficOnly = false     @State private var showmoderatetrafficOnly = false     @State private var showhightrafficOnly = false     @State private var showbeginnerOnly = false     @State private var showintermediateOnly = false     @State private var showexpertOnly = false     @Binding var rating: Int     @State private var review: String = ""               var filteredLandmarks: [Landmark] {         landmarksVM.landmarks.filter { landmark in             (!showpaidOnly || landmark.ispaid)             (!showfreeOnly || landmark.isfree)             (!showstreetOnly || landmark.isstreet)             (!showforest || landmark.isforest)             (!showdunesOnly || landmark.isdunes)             (!showwaterOnly || landmark.iswater)             (!showlowtrafficOnly || landmark.islowtraffic)             (!showmoderatetrafficOnly || landmark.ismoderatetraffic)             (!showhightrafficOnly || landmark.ishightraffic)             (!showbeginnerOnly || landmark.isbeginner)             (!showintermediateOnly || landmark.isintermediate) (!showexpertOnly || landmark.isexpert)                     }     }               var body: some View {         NavigationView {             List {                                          ForEach(filteredLandmarks){                     thislandmark in                     NavigationLink (                         destination: LandmarkDetail(landmark: thislansmark, rating: .constant(0))){                                                                                         }             }         }         .navigationTitle("Filtered Landmarks")         }         if landmark.isFavorite {             Image (systemName: "heart.fill")                 .foregroundColor(.purple)         }     }      } struct FilterList_Previews: PreviewProvider {     static var previews: some View {         LandmarkList( rating: .constant(0))             .environmentObject(LandmarksViewModel())     } }
0
0
1.1k
Sep ’22
What is the best and pocket friendly Basic Server and Database for iOS app
Im extremely green when it comes to coding and creating applications and would love guidance. I have been doing research on possible databases for iOS apps, but Im not sure what are best for my type of application, just some backend im currency using JSON file for information. My application includes users logging in and creating profiles as well as reviewing and rating locations. Im looking for something that would work for this I was considering CloudKit, but im not sure it best for the reviews and rating of the locations, upon my research i saw it was best for thing such as longins and profiles. Also is Xcode Server still a thing? Im looking for server suggestions and database suggestions. thank you!
0
0
1.1k
Sep ’22
what is the correct way to add mapmakers in Xcode.
I have searched this site and StackOVerflow forums and Im unable to find an answer that helps me figure out how to add MapMarkers to my MapView. I am adding onto the SwiftUI Landmarks Tutorial, I want to be able to see the marker when i click on the landmark row name and the map shows up for that location and i want to have a map view that shows MapMarkers of all locations in that area. This is my MapView import SwiftUI import MapKit struct MapView: View { var coordinate: CLLocationCoordinate2D var landmark: Landmark @State private var region = MKCoordinateRegion() var body: some View { Map(coordinateRegion: $region) .onAppear { setRegion(coordinate) MapMarkerTool(coordinate: landmark.locationCoordinate) }//onappear }//body.view private func setRegion(_ coordinate: CLLocationCoordinate2D) { region = MKCoordinateRegion( center: coordinate, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)) }//private func }//struct mapview struct MapView_Previews: PreviewProvider { static var previews: some View { MapView(coordinate:CLLocationCoordinate2D(latitude: 36.4786, longitude: -117.0745), landmark: landmark) }//view }//preview This is my MapMarkerTool import SwiftUI import MapKit struct MapMarkerTool: Identifiable { let id: UUID let location: CLLocationCoordinate2D init(id: UUID = UUID(), lat: Double, long: Double) { self.id = id self.location = CLLocationCoordinate2D( ) } } struct PinAnnotationMapView: View { let place: MapMarkerTool @State var region: MKCoordinateRegion var body: some View { Map(coordinateRegion: $region, annotationItems: [place]) { place in MapMarker(coordinate: place.location, tint: Color.purple) } } } //Prieview was deleted because i wasn't sure if it was needed or not and it kept showing up as an error.
0
0
711
Sep ’22