So I call FetchRequest to get the data.
When I print out isFavorite I can see all the data in my coredata model, but I'm not sure how I can run a contain that data.
This is what I thought would work
I get the error Cannot convert value of type 'String' to expected argument type 'FetchedResults<FavoriteItem>.Element' (aka 'FavoriteItem')
Do I need to do a foreach and check each item?
Code Block @FetchRequest(fetchRequest: FavoriteItem.getAllFavorites()) var isFavorite:FetchedResults<FavoriteItem>
When I print out isFavorite I can see all the data in my coredata model, but I'm not sure how I can run a contain that data.
This is what I thought would work
Code Block if isFavorite.contains(foo.name) { print("it's already there nerd") }
I get the error Cannot convert value of type 'String' to expected argument type 'FetchedResults<FavoriteItem>.Element' (aka 'FavoriteItem')
Do I need to do a foreach and check each item?
Thanks for showing the definition.Here's the definition
Assuming you want to find a FavoriteItem with its name property matching the String value foo.name, you can write something like this:
Code Block if favoriteRunClubItem.contains(where: {$0.name == foo.name}) { print("it's already there nerd") }