I'm using core data and when I try to read my properties, they are read as numbers such as 0 and 1. Here is my Core Data set up. My end goal is to save a boolean to true or false and then read read it as such. Am I doing something wrong in my setup, or missing something? I've looked that the post iPhone: Save boolean into Core Data and besides being in OBJ C, I believe booleans are available now in the Datamodel options.
func saveFilters(bathAny: Bool, bath1: Bool, bath2: Bool, bath3: Bool, bath4: Bool){
let context = getContext()
let entity = NSEntityDescription.entity(forEntityName: "FilterCoreDataObj", in: context)
let transc = NSManagedObject(entity: entity!, insertInto: context)
//SET ENTITY VALUES
transc.setValue(bathAny, forKey: "bathAny")
transc.setValue(bath1, forKey: "bath1")
transc.setValue(bath2, forKey: "bath2")
transc.setValue(bath3, forKey: "bath3")
transc.setValue(bath4, forKey: "bath4")
do {
try context.save()
print("saved")
} catch let error as NSError {
print("could not save \(error), \(error.userInfo)")
} catch {
}
}
Read Func
func getTranscriptions(bathAny: Bool, bath1: Bool, bath2: Bool, bath3: Bool, bath4: Bool) {
let fetchRequest: NSFetchRequest<FilterCoreDataObj> = FilterCoreDataObj.fetchRequest()
do {
let searchResults = try getContext().fetch(fetchRequest)
print("num of results = \(searchResults.count)")
for trans in searchResults {
print("bath 1 \(trans.value(forKey: "bath1"))")
}
} catch {
print("Error with request: \(error)")
}
}