JohnEstropia / CoreStore

Unleashing the real power of Core Data with the elegance and safety of Swift
MIT License
4.01k stars 255 forks source link

How to creat a FetchedResultsController? #316

Open jshl8612 opened 5 years ago

jshl8612 commented 5 years ago

Would you like to tell me the right way to make a FetchedResultsController?

let fecthController = dataStack.createFetchedResultsController(From<Food>(), SectionBy<Food>("name"), OrderBy<Food>(.ascending("foodID")))

With above code, fetchedObjects is always nil.

JohnEstropia commented 5 years ago

Is there any reason you prefer NSFetchedResultsController instead of ListMonitor?

As for your question, there's nothing that looks wrong in your code so there must be some other problem. Are you seeing any error logs in the console?

jshl8612 commented 5 years ago

Is there any reason you prefer NSFetchedResultsController instead of ListMonitor?

As for your question, there's nothing that looks wrong in your code so there must be some other problem. Are you seeing any error logs in the console?

Because the ListMonitor<Food> couldn't set to ListMonitor<SuperClassOfFood>.

I have a BaseViewController contains NSFetchedResultsController to deal with most of the same job, and overriding the get function in subclass.

There was no error logs in console.