ios - non-optional relations one-to-one failed to save with 1570 error sometimes -


i have task , person classes. task has relationship one-to-one person, relation called "assignee". have nsmanagedobject inheritors both classes. getting instance of person (with aid of nsfetchrequest), , create new task (with nsentitydescription), ,

task.assignee = person; [context save:&error]; 

some times saves, of time getting “cocoa error 1570” saying "assignee" null!

how be?

  • i added assert(task.assignee) before saving
  • i check [task validateforinsert:&error]; , error empty!!
  • i using same context fetched person second ago
  • nobody touches in background

and funniest thing: when check "optional" in relation, works! saves correct data: task person.

is bug or what?

looks did stupid threading mistake.

i had context nsprivatequeueconcurrencytype, , used objects obtained on main thread, not allowed (managed objects not thread safe). should switch nsmainqueueconcurrencytype or use managedobjectid refetch objects different context (on correct thread).


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -