Note that there are some explanatory texts on larger screens.

plurals
  1. POFetched Properties, cross store relationships
    primarykey
    data
    text
    <p>I've got a store that is synchronized externally and a store that is unique to the application instance, so in order to cleanly differentiate the two I want to have some join entities between them and then resolve through to the entities between using Fetched Properties, as "discussed" in the Core Data Programming Guide:</p> <p>developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html#//apple_ref/doc/uid/TP40001857-SW5</p> <p>I think I just don't really "get" how Fetched Properties are supposed to be used - and I've spent a fair number of hours looking for examples with no real luck.</p> <p>The way I think of it is,</p> <p>I have the following Entities each in a different store <strong>Foo</strong> with attribute <em>relatedBarName</em> in store <strong>A</strong> <strong>Bar</strong> with attribute <em>barName</em> in store <strong>B</strong></p> <p>I need to create a fetched property on Foo named <em>findRelatedBar</em> that relates <strong>Foo</strong> to <strong>Bar</strong> loosely through <em>barName</em> = <em>relatedBarName</em>.</p> <p>However, I don't understand how since <strong>Foo</strong> and <strong>Bar</strong> are in different stores how to declare any relationship of any sort, whether through the fetched property or not, from <strong>Foo</strong> to <strong>Bar</strong>? </p> <p>The predicate builder in XCode seems to want a Destination entity. If they are in different schemas, how can you declare the destination? If you don't declare a destination, how do you at runtime indicate that <em>findRelatedBar</em> on <strong>Foo</strong> is describing <strong>Bar</strong>?</p> <p>Otherwise, do they need to be in the same schema but just stored in different stores?</p> <ul> <li>In crafting this question, I thought of these questions and answered them myself by more focused examination of the documentation. I assume if I found it confusing, others might as well, so I'll inline them with this post to make it easier to find related answers to fetched properties / core data stores.</li> </ul> <p>Q) If a store coordinator have more than one store associated with it of the same schema, how do insertions know which store to insert to?</p> <p>A) <a href="http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/NSManagedObjectContext.html#//apple_ref/occ/instm/NSManagedObjectContext/assignObject:toPersistentStore:" rel="nofollow noreferrer" title="You use the assignObject method on the managed object context">You use the assignObject:toPersistentStore: method on the managed object context.</a></p> <p>Q) What does <strong>FETCH_SOURCE</strong> refer to in specific?</p> <p>A) It's simply the managed object which has the fetched property associated with it. Sort of like "<strong>self</strong>"</p> <p>Q) What does <strong>FETCHED_PROPERTY</strong> refer to in specific?</p> <p>A) It is a reference to the fetched property description instance you are using to query with - you can use this to insert per query variable substitution. By setting a property (as in the Core Data Programming example) on the userInfo of the property description instance you're using, you can inject that value into the expression.</p> <p>Thanks!!!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload