Fetched Properties, cross store relationships

Fetched Properties, cross store relationships

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:


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.

The way I think of it is,

I have the following Entities each in a different store Foo with attribute relatedBarName in store A Bar with attribute barName in store B

I need to create a fetched property on Foo named findRelatedBar that relates Foo to Bar loosely through barName = relatedBarName.

However, I don't understand how since Foo and Bar are in different stores how to declare any relationship of any sort, whether through the fetched property or not, from Foo to Bar?

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 findRelatedBar on Foo is describing Bar?

Otherwise, do they need to be in the same schema but just stored in different stores?

  • 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.

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?

A) You use the assignObject:toPersistentStore: method on the managed object context.

Q) What does FETCH_SOURCE refer to in specific?

A) It's simply the managed object which has the fetched property associated with it. Sort of like "self"

Q) What does FETCHED_PROPERTY refer to in specific?

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.


How to hide the Dock icon


Cocoa QTKit and recording movies
The answer is:. Cocoa without Interface Builder, initialize an instance of app controller? Yes, you need to did a cross store fetched property with shared schemas. How to set up HTTP connection in a special class? If you did this, you need to make sure you attrialthough e the inserts with the assignObject:: method as described in the question. How to design a static class? However, due to the limitations of the SQLLITE persistent store, natural things like IN $FETCH_SOURCE.attrialthough e did not work.. What is a referencing outlet?
Cross-platform development - Go with a cross-platform UI toolkit or native on multiple platforms?NSMutableArray count always returns zero


Q) If a store coordinator have more than one store associated with it of the same schema, how did insertions know which store to insert to?.
This is what configurations are for. You create a configuration for each store and then assign entities to this configuration. You then create the store with the proper configuration. When you save the context, each entity will automatically go to the correct store. .

75 out of 100 based on 70 user ratings 585 reviews