ios - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet addObject:]: attempt to insert nil' -


i'm trying run loop in app delegate initialize core data crashes after random number of runs without changing of code , it's @ managedcontext.save(). check data it's trying save when crashes , there's nothing should problem.

for(var = 0; <= bodycount; i++){     let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate     let managedcontext = appdelegate.managedobjectcontext     let entity =  nsentitydescription.entityforname("bitem", inmanagedobjectcontext:managedcontext)     let newitem = nsmanagedobject(entity: entity!, insertintomanagedobjectcontext: managedcontext)     newitem.setvalue(itemhref, forkey: "href")     newitem.setvalue(itemtitle, forkey: "title")     newitem.setvalue(itemurl, forkey: "url")     newitem.setvalue(itemindex, forkey: "index")     newitem.setvalue(itemsubtitle, forkey: "subtitle")     newitem.setvalue(itemimgsrc, forkey: "imgsrc")      {         try managedcontext.save()     }catch let error nserror  {         print("could not save body item \(error), \(error.userinfo)")     } } 

the errors:

coredata: error: serious application error. exception caught during core data change processing. bug within observer of nsmanagedobjectcontextobjectsdidchangenotification. -[__nscfset addobject:]: attempt insert nil userinfo (null)

terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfset addobject:]: attempt insert nil'


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -