I'm building a todo app, and I want to create a "History" page in the app.
Right now I have a model file and I created in it a "todo" entity with some different attributes (body, status , time etc), and im using core data to holds those todo's.
So I created a button to the "History" page which is a table view, and Now im trying to figure out how to keep the todo's that was marked done and populate the History page (table view) cells with this todo's.
So I thought that in the Home view controller I will create an NSMutableArray property called "todos", And ill create a method in the Home view controller .m file that is adding todos to the todos property, import the home view controller to the history table view controller and populate it's cells with the todos array property.
How bad is this solution?
thanks
You should not be using an array to hold your todos. This could potentially result in excessive memory use and performance degradation. To display Core Data entities in a table view, use the
NSFetchedResultsController
class which was specifically designed for this purpose.You can find boilerplate code from the Xcode template (choose Master-Detail, check "Core Data" and look at the master view controller).
In your lazy initiator of the fetched results controller, add this predicate:
or instead of
done
use whatever flag you have included in your model to indicate that an item should be shown in the history view.