Hey,
Regarding Chapter 2, Section “Propogating a managed context”. My question is to do with why I can’t comment out insertSampleData after running the app once. The data is inserted into CoreDate, but I still need to run the func InsertSampleData. Presumably because something in the first bit of code, which just counts the number of objects in the request, is needed.
func insertSampleData()
{
// check CData for entries (and end here if there are)
let fetchRequest = NSFetchRequest(entityName: “Bowtie”)
fetchRequest.predicate = NSPredicate(format: “searchKey != nil”)
let count = managedContext.countForFetchRequest(fetchRequest, error: nil)
if count > 0 { return }
…}
Could you please clarify why it appears that I need to run this code before I can successfully executeFetchRequest from CoreData?
Thanks!