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 didfinishlaunchingwithoptions
method. , 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
Post a Comment