ios - CoreData - NSManagedObject SubObject Only Stored in one Object at a time -


i have 2 coredata entities: list , item. list contains relationship destination of item. to-many relationship (list entities can contain many items)

list = {   id: string,   name: string   items: <item> }  item = {   id: string,   name: string } 

now, let's have:
2 total lists -> list_1 , list_2
3 total items: item_1, item_2, , item_3.

the lists looks like:

list_1 = {   id: "1001",   name: "foo"   items: <item_1, item_2> }  list_2 = {   id: "1002",   name: "bar"   items: <item_2, item_3> } 

when make fetch against coredata experiencing inconsistent results, , inconsistency based on last list loaded in app.

for example, if use app , last list load list_1 when query items in list_1 returned:

item_1, item_2

however, if use app , last list load list_2 when query items in list_1 returned:

item_1 (only....no item_2?!) if "moved" out of list_1 , list_2 since list_2 last list visited contained `item_2.

are coredata objects stored part of one-to-many relationship allowed exist in 1 coredata object @ time? see wrong how approaching this?

any appreciated! thanks

it seems have 1 many relationship between list , items:

list <-->>items 

one many

that mean 1 list can have many items 1 item can have 1 list.

but want items able belong many lists, need create many many relationship between list , items

list <<-->>items 

in case 1 list can have many items 1 item can belong many lists.

many many

i hope helps


Comments