ios - Frequently Accessed Objects/Classes -


within swift application, there 2 classes interact in 75% of app. 1 set of settings called usersettings, , other called job. these both stored in sqllite.

most of time it's reading values set, , on 1 areas writes. seems strange have keep reinstantiating settings , job services communicate database me same object i'm accessing across board.

in case this, options me see either

  1. constantly reading/writing database, or
  2. do sort of singleton accessed throughout entire app.

i'm not sure how swift changes in terms of arriving @ answer question, wanted seek of stack overflow. how set object can access throughout entire app? or not ideal , instead need db every time?

thanks much.

i recommend read how core data works, know managing own store, architecture works fine. summary can create "context object"(this singleton) interacts store (sqlite) creating managed objects, work objects associated "context object", , when ever need save changes, ask "context object" write managed objects in store.

your managed objects need copy of "context object" objects, when ask "save" data "context object" copy managed objects. save multithread coding. (your context object should work on serialized queue).

again summary, should read how core data works better picture.

edit:

read blog: http://www.objc.io/issue-4/core-data-overview.html difference need 1 store , 1 context object.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -