• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
clarifications about coredata sub to-many entities fetching
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

clarifications about coredata sub to-many entities fetching


  • Subject: clarifications about coredata sub to-many entities fetching
  • From: Nicolas Berloquin <email@hidden>
  • Date: Sat, 9 Oct 2010 11:55:01 +0200

Hi !

  I'm fairly new at using coreData on and I'd like to have some
clarifications on managedObjects and contexts usage.
I have a model where a top entity has a couple to-many relationships, which
each have to-many relationships
to other entities.
something like this :

A
to-many -> B
to-many -> C

B
to-many -> D

C
to-many -> E

(I skipped the other attributes in the entities)

I have a set of As, that I fetch when my app loads, and I dig into As
through a UITableView.
I show a list of As, and when the user taps an A, I show a detail view of
its contents.
The user can then access the table of Bs and Cs. And add Ds and Es...

What I'd like to know is what I should do when I show the list of Bs for
example.

Should I do a new fetch (with a different fetchRequest) on the Bs, and have
this as a new context ?
I'm not sure how do NSIndexPath work with my setup ?
My feeling is that if I do the new fetchRequest on the Bs, then a path of
0.x will give me
the "array" indexes of my Bs.
But if I stay with the original context, how can it know of the two separate
inner sets (B,C) ?

On the other hand, the same data has already been loaded when I loaded the
As.
(well, they may have only been faulted). Is it usual to "re-load" some parts
of the tree ?

Also, when adding Ds should I pass the managed B object to my
BviewController and do
[Binstance addDObject: newD];
or have B as the base of the new context and do

[NSEntityDescription insertNewObjectForEntityForName:@"D" ...]

or if I didn't do any new fetchRequest (staying with the As), will

[Binstance addDObject: newD]; still do the relevant work in the hierarchy ?

and last question (see I'm still a bit confused about the whole thing :))
if I keep the context I got when loading the original As, and I do a
[context save:] of new Ds, will it be as efficient as if I was to do the
same thing
with a context created with Bs as a fetchRequest ?


thanks for any enlightenments.
I get the feeling that one can use a coredata hierarchy almost as directly
as if it
was a plain object hierarchy, but I'd like to make sure I'm not missing
something
along the way !

thanks !
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: clarifications about coredata sub to-many entities fetching
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: ivars and fundamental types
  • Next by Date: Re: confused about floats
  • Previous by thread: Re: SRV record lookup
  • Next by thread: Re: clarifications about coredata sub to-many entities fetching
  • Index(es):
    • Date
    • Thread