Closed HenrikSwahn closed 8 years ago
Updates to objects are not saved, needs to be done in order to get the ratings to work. This is also useful for the edit view since it will be using the same functions.
if result.count > 0 { let managedObject = result[0] as MusicStore managedObject.setValue(updatedMusic.title, forKey: "title") managedObject.setValue(updatedMusic.genre, forKey: "genre") managedObject.setValue(updatedMusic.albumArtist, forKey: "albumArtist") managedObject.setValue(updatedMusic.runtime.getTotalInSeconds(), forKey: "runtime") //result[0].tracks = NSSet(array: updatedMusic.trackList) managedObject.setValue(updatedMusic.releaseYear, forKey: "releaseYear") managedObject.setValue(updatedMusic.desc, forKey: "desc") managedObject.setValue(updatedMusic.ownerLocation, forKey: "ownerLocation") managedObject.setValue(updatedMusic.owningType?.rawValue, forKey: "owningType") managedObject.setValue(updatedMusic.format?.rawValue, forKey: "format") managedObject.setValue(updatedMusic.rating, forKey: "rating") managedObject.setValue(UIImageJPEGRepresentation(updatedMusic.coverArt!, 1), forKey: "coverArt") do { try managedObjectContext.save() } catch { fatalError("Error updating object in core data") } } }
No real bug, object was updated by the managedContext. The error was that rating was not read from the db when we fetched the entries.
Updates to objects are not saved, needs to be done in order to get the ratings to work. This is also useful for the edit view since it will be using the same functions.