ios - Not sure where the core data code should go in the MVC -


in app i'm working on, use core data store content. populate database in appdelegate's didfinishlaunchingwithoptionsmethod. , in view controller, i'm extracting required data using nsfetchrequest.

my question is, code related extracting data should in view controller? or should create separate methods in nsmanagedobject subclasses generated entities , call them view controller?

can please shed light on this?

thank you.

you should create model class, means like:

@interface dataimporter : nsobject @property(nonatomic, readonly) coredatamanager *coredatamanager;   - (id)initwithcoredatamanager:(coredatamanager *)coredatamanager;   - (void)importdatawithcompletioncallback:(void (^)())completionblock; @end 

it's not nsmanagedobject subclass, it's object responsible importing data coredata store. importdatawithcompletioncallback can e.g. create necessary nsmanagendobject objects (depending on json) , save them, in background, call callback block after completion.

subclassing nsmanagendobject not way follow.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -