ios - Saving in Core Data -


at abcviewcontroller.m

product *pro = [nsentitydescriptioninsertnewobjectforentityforname:@"product" inmanagedobjectcontext:_appdelegate.managedobjectcontext];            pro.name = _nametext.text;         [_context insertobject:pro];         [_appdelegate savecontext]; 

savecontext in appdelegate contains

- (void)savecontext {     nsmanagedobjectcontext *managedobjectcontext = self.managedobjectcontext;     if (managedobjectcontext != nil) {         nserror *error = nil;         if ([managedobjectcontext haschanges] && ![managedobjectcontext save:&error]) {             // replace implementation code handle error appropriately.             // abort() causes application generate crash log , terminate. should not use function in shipping application, although may useful during development.             nslog(@"unresolved error %@, %@", error, [error userinfo]);             abort();         }      } } 

any need of "[_context insertobject:pro];" @ abcviewcontroller.m saving coredata file context????

unless _appdelegate.managedobjectcontext , _context 2 different nsmanagedobjectcontext's, don't need explicitly call insertobject inserted new product object nsentitydescriptioninsertnewobjectforentityforname


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -