Hello Claude31:I edited the code as below and am getting a debug list as below:func preloadScq() {
let backgroundContext = persistentContainer.newBackgroundContext()
persistentContainer.viewContext.automaticallyMergesChangesFromParent = true
_ = NSEntityDescription.entity(forEntityName: "SCQ", in: backgroundContext)!
print("Call to preload Data Starts Now")
let preloadedDataKey = "didPreloadData"
UserDefaults.standard.removeObject(forKey: preloadedDataKey)
let userDefaults = UserDefaults.standard
if userDefaults.bool(forKey: preloadedDataKey) == false {
guard let plistUrl = Bundle.main.url(forResource: "SCQ", withExtension:"plist") else {
return
}
do {
let plistData = try Data(contentsOf: plistUrl)
let scqList = try PropertyListDecoder().decode([Scq].self, from: plistData)
let scqObjects = NSEntityDescription.insertNewObject(forEntityName: "SCQ", into: backgroundContext)
print(scqList)
for scqName in scqList {
let scqObject = SCQ(context: backgroundContext)
// print(scqName)
scqObject.answer = ("answer")
print(scqName)
}
try backgroundContext.save()
print("SAVED")
// userDefaults.set (true, forKey: preLoadedDataKey)
} catch {
print(error)
}
}
}I get a print of the plist contents:[ScorCentMasterReview.AppDelegate.Scq(answer: "1", distractor1: "R", distractor2: "Wr", distractor3: "DK", distractor4: "not here", distractor5: "not here", grade: "2", id: "403", qid: "1", question: "If the word is spelled correctly choose R. If it is not spelled correctly choose Wr. If you don’t know choose DK. The noise was TERRIBLE.", qValue: "1000", skill: "Spell Terrible Correctly", subject: "ELA", topic: "SPELLING")But The object that is saved is not the value for "answer" but the word "answer":CoreData: sql: INSERT INTO ZSCQ(Z_PK, Z_ENT, Z_OPT, ZANSWER, ZDIFFICULTYLEVEL, ZDISTRACTOR1, ZDISTRACTOR2, ZDISTRACTOR3, ZDISTRACTOR4, ZDISTRACTOR5, ZGRADE, ZID, ZQVALUE, ZQID, ZQUESTION, ZSKILL, ZSUBJECT, ZTOPIC) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)CoreData: details: SQLite bind[0] = (int64)2545CoreData: details: SQLite bind[1] = (int64)7CoreData: details: SQLite bind[2] = (int64)1CoreData: details: SQLite bind[3] = "answer"