So I'm building a pretty basic sheet music editor in swift. I'm using CoreData to store and update the songs. The add, delete and update methods change both the data in the songs array and add stuff to my CoreData model. I'm wondering if this is a dumb way to structure my code. Should I bypass the songs array and interact with Core Data directly?
Code:
class DataStore {
var songs: Array<Song> = [Song]()
init() { songs = loadSongsFromCoreData() }
func addSong(song: Song) { ... }
func deleteSongAtIndex(index: Int) { ... }
func updateSongAtIndex(song: Song, index: Int) { ... }
func loadSongsFromCoreData() -> Array<Song> { ... }
}
Last edited: