I have an Artist and album Entity. I am able to retrieve all of the covers from the Album entity. However I cant figure out how to fetch only covers assigned to an specific artist. As far as I understand this should have some kind of Predicate with specific condition to retrieve that. I am trying to work on the core data relationship to retrieve a cover attribute from the Album entity. Please see attached screens from the core data editor. As well as the code I am trying to implement.
var albums = [Album]()
let request = NSFetchRequest<Album>(entityName: "Album")
//request.predicate = NSPredicate(format: "recordArtist = %@", albums)
do {
albums = try context.fetch(request)
for cover in albums {
if ((currentArtist?.name) != nil){
print(currentArtist.cover)
}
}
}
catch { print(error)
}