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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -