Post

Replies

Boosts

Views

Activity

Reply to JSON DATA CORRUPTED ERROR
ataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around line 1, column 0." UserInfo={NSDebugDescription=Invalid value around line 1, column 0., NSJSONSerializationErrorIndex=0}))) dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/eshansingh/Library/Developer/Xcode/DerivedData/EmployeeManagement-bfquzjwgjywziwfrfyygkodtlgop/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/eshansingh/Library/Developer/Xcode/DerivedData/EmployeeManagement-bfquzjwgjywziwfrfyygkodtlgop/Build/Products/Debug-iphonesimulator CoreSimulator 783.5 - Device: iPhone 11 (118C63BF-B908-4454-8870-FC609C41BA8D) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 11 (lldb)
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
My Views Code are as follows Orders are arranged properly. in the actual app struct ETabView: View {     var body: some View {         TabView{             PeopleView().tabItem{                 VStack{                    Image(systemName:"person.3")                    Text("Current Employees")                 }                                  }             DisplayPreferenceView().tabItem{                 VStack{                  Image(systemName:"gearshape")                  Text("Perference")                 }             }                                                                          }     } } struct TabView_Previews: PreviewProvider {     static var previews: some View {         ETabView()     } } struct PeopleView: View { @EnvironmentObject var model:EmployeeModel     var body: some View {         List(model.person){ p in             VStack{             Text("Name:" + p.Name)             Text("Address:" + p.Address)             Text("Company:" + p.Company)             Text("YearsofExperience:" + String(p.YearsofExperience))             }         }     } } struct PeopleView_Previews: PreviewProvider {     static var previews: some View {         PeopleView()     } starting point of app ```import SwiftUI @main struct EmployeeManagementApp: App {     var body: some Scene {         WindowGroup {             ETabView()                 .environmentObject(EmployeeModel())         }     } }
Jan ’22
Reply to JSON DATA CORRUPTED ERROR
my data fetching code is as follows (forgot to add in the question) import Foundation class DataFetching {          static func getLocalData() -> [Person] {                  // Parse local json file                  // Get a url path to the json file         let pathString = Bundle.main.path(forResource: "data", ofType: "json")                  // Check if pathString is not nil, otherwise...         guard pathString != nil else {             return [Person]()         }                  // Create a url object         let url = URL(fileURLWithPath: pathString!)                  do {             // Create a data object             let data = try Data(contentsOf: url)                          // Decode the data with a JSON decoder             let decoder = JSONDecoder()                          do {                                  let EmployeeData = try decoder.decode([Person].self, from: data)                                  // Add the unique IDs                 for e in EmployeeData {                     e.id = UUID()                 }                 // Return the recipes                 return EmployeeData             }             catch {                 // error with parsing json                 print(error)             }         }         catch {             // error with getting data             print(error)         }                  return [Person]()     }      }
Jan ’22