database - Inserting and updating the records in coredata using iOS -


when ios mobile app launches first time, based on user clicks connecting server.

let me explain in detail:

  1. initially connecting server, parse information , store array. so,am able insert array of elements in database.
  2. now app launches next time, base on user clicks able to different array of elements.
  3. now able retrieve records database , need check latest records has been inserted in database or not?

please let know, how insert records not available in database.

do use coredata magicalrecords?

here code snippet of check if there record existing , saving data:

uiapplication *application = [uiapplication sharedapplication];  __block uibackgroundtaskidentifier bgtask = [application beginbackgroundtaskwithexpirationhandler:^{     [application endbackgroundtask:bgtask];     bgtask = uibackgroundtaskinvalid; }];  [magicalrecord savewithblock:^(nsmanagedobjectcontext *localcontext) {     chatmessage* chatmessage = [chatmessage mr_findfirstbyattribute:@"messageid" withvalue:@198964 incontext:[nsmanagedobjectcontext mr_rootsavingcontext]];      if(!chatmessage) //if there isn't record messageid 198964 programmatically create 1        chatmessage = [chatmessage mr_createincontext:localcontext];      [chatmessage set...];     .........   } completion:^(bool success, nserror *error) {     [application endbackgroundtask:bgtask];     bgtask = uibackgroundtaskinvalid; }];  

Popular posts from this blog