Based on the data model here: Photographer<——->>Photo
When the user goes to add a Photo, the user also specifies what Photographer took said picture. When the user decides to save the Photo, there is the possibility that the Photographer doesn’t exist yet. After executing a NSFetchRequest to get a list of all instances of Photographer, how do I check if the NSMutableArray(photographerArray) contains an object that has the same fullName attribute as what the user is currently adding?
The naive way would be to simply get all the
fullNameof the array and check if it’s in it.However, it would be way more easier to put that directly in your fetch request. Just add a predicate to it.
If the result of the fetch is empty, then the photographer doesn’t exist yet.