ios - correct use of mvc principle between a view controller to a table view -


i'm building todo app, , want create "history" page in app.

right have model file , created in "todo" entity different attributes (body, status , time etc), , im using core data holds todo's.

so created button "history" page table view, , im trying figure out how keep todo's marked done , populate history page (table view) cells todo's.

so thought in home view controller create nsmutablearray property called "todos", , ill create method in home view controller .m file adding todos todos property, import home view controller history table view controller , populate it's cells todos array property.

how bad solution?

thanks

you should not using array hold todos. potentially result in excessive memory use , performance degradation. display core data entities in table view, use nsfetchedresultscontroller class designed purpose.

you can find boilerplate code xcode template (choose master-detail, check "core data" , @ master view controller).

in lazy initiator of fetched results controller, add predicate:

request.predicate = [nspredicate predicatewithformat:@"done = yes"]; 

or instead of done use whatever flag have included in model indicate item should shown in history view.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -