|
- {"abstract":[{"text":"Seeds the database with initial data.","type":"text"}],"kind":"symbol","hierarchy":{"paths":[["doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager"]]},"sections":[],"primaryContentSections":[{"declarations":[{"tokens":[{"kind":"attribute","text":"@"},{"preciseIdentifier":"s:ScM","text":"MainActor","kind":"attribute"},{"kind":"text","text":" "},{"kind":"keyword","text":"func"},{"text":" ","kind":"text"},{"text":"seedData","kind":"identifier"},{"text":"()","kind":"text"}],"platforms":["iOS"],"languages":["swift"]}],"kind":"declarations"},{"content":[{"level":2,"anchor":"discussion","text":"Discussion","type":"heading"},{"syntax":"swift","code":["func seedData() {"," let context = container.viewContext"," guard let url = Bundle.main.url(forResource: \"seedData\", withExtension: \"json\") else {"," fatalError(\"Could not find seed data file.\")"," }",""," do {"," let data = try Data(contentsOf: url)"," let decoder = JSONDecoder()"," let objects = try decoder.decode([UserModel].self, from: data)"," "," for object in objects {"," let entity = NSEntityDescription.entity(forEntityName: \"User\", in: context)!"," let user = NSManagedObject(entity: entity, insertInto: context)"," user.setValue(UUID(), forKey: \"id\")"," user.setValue(object.firstName, forKey: \"firstName\")"," user.setValue(object.lastName, forKey: \"lastName\")"," user.setValue(object.userName, forKey: \"userName\")"," user.setValue(object.password, forKey: \"password\")"," user.setValue(object.token, forKey: \"token\")"," }"," "," try context.save()"," fetchData()"," } catch let error as NSError {"," print(\"Could not save. \\(error), \\(error.userInfo)\")"," }","}"],"type":"codeListing"}],"kind":"content"}],"variants":[{"traits":[{"interfaceLanguage":"swift"}],"paths":["\/documentation\/fueling\/coredatamanager\/seeddata()"]}],"schemaVersion":{"minor":3,"major":0,"patch":0},"metadata":{"roleHeading":"Instance Method","modules":[{"name":"Fueling"}],"externalID":"s:7Fueling15CoreDataManagerC04seedC0yyF","role":"symbol","title":"seedData()","symbolKind":"method","fragments":[{"text":"func","kind":"keyword"},{"kind":"text","text":" "},{"text":"seedData","kind":"identifier"},{"kind":"text","text":"()"}]},"identifier":{"interfaceLanguage":"swift","url":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager\/seedData()"},"references":{"doc://rpm.com.production.Scanner/documentation/Fueling/CoreDataManager/seedData()":{"abstract":[{"text":"Seeds the database with initial data.","type":"text"}],"kind":"symbol","fragments":[{"kind":"keyword","text":"func"},{"text":" ","kind":"text"},{"kind":"identifier","text":"seedData"},{"text":"()","kind":"text"}],"title":"seedData()","type":"topic","url":"\/documentation\/fueling\/coredatamanager\/seeddata()","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager\/seedData()","role":"symbol"},"doc://rpm.com.production.Scanner/documentation/Fueling":{"kind":"symbol","url":"\/documentation\/fueling","title":"Fueling","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","abstract":[{"type":"text","text":"The Scanner app is designed to facilitate secure and efficient fuel management operations, primarily focusing on user authentication, fuel data collection, and network communication. The app includes several key features to ensure seamless and reliable interactions between users and the backend systems, leveraging technologies like WebSockets, Core Data, and biometric authentication."}],"type":"topic","role":"collection"},"doc://rpm.com.production.Scanner/documentation/Fueling/CoreDataManager":{"fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"text":"CoreDataManager","kind":"identifier"}],"type":"topic","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager","kind":"symbol","title":"CoreDataManager","abstract":[],"navigatorTitle":[{"text":"CoreDataManager","kind":"identifier"}],"url":"\/documentation\/fueling\/coredatamanager","role":"symbol"}}}
|