Core-data save problem

  • Hi,

    I have a core data document based program that, for now, parses a gpx
    file and stores the information in a core-data model. All works fine,
    until I try to save the data, then I am sometimes present with a
    dialog saying:
    "The document “Untitled” could not be saved as “pktest.”. Cannot save
    objects with references outside of their own stores."

    I tried googling for the error message but nothing shows up. Any
    pointers to what may cause this error?
    Thanks,

    Dirkjan Krijnders
  • > I try to save the data, then I am sometimes present with a
    > dialog saying:
    > "The document “Untitled” could not be saved as “pktest.”. Cannot save
    > objects with references outside of their own stores."

    Dirkjan,

    How many persistent stores have you added to the
    NSPersistentStoreCoordinator ?  That's
    NSManagedObjectExternalRelationshipError.  Core Data does not support
    direct relationships between objects being stored in different files
    (persistent stores).  The iClass example in /Developer/Examples/
    CoreData/ shows how you can perform an indirect style of ad hoc cross
    store relationships  by serializing the -URIRepesentation of an
    NSManagedObjectID.

    Also, I keep these and other similar breakpoints handy in my
    ~/.gdbinit file:

    future-break objc_exception_throw
    future-break +[NSError errorWithDomain:code:userInfo:]
    future-break handleFailureInMethod:object:file:lineNumber:description:
    future-break handleFailureInFunction:file:lineNumber:description:
    future-break malloc_printf
    future-break malloc_error_break

    - Ben
  • greetings!

    I'm trying to figure out how to dynamically (in code) set up a fetched
    property with a Coredata in-memory store. The documentation is not
    detailed enough for me to quite see what the correct way to set the
    code up is and I'm not finding much in the way of useful sample code
    when searching on NSFetchedPropertyDescription.

    suppose I have 3 enties:

    "box" which has a property  "storyMapId"

    "map" which has properties "mapId" and "storyId"

    "story" which has property "storyId2"

    box.storyMapId has a 1-1 relationship with map.mapId
    map.storyId has a 1-many relationship with story.storyId2

    What is the correct way to programmatically add a fetched property to
    the box  to get the list of stories for a given box managed object?

    thanks,
    James Gregurich
    Engineering Manager
    Markzware
  • Create an NSFetechedPropertyDescription by setting up a fetch request
    in code, then add the property using the setProperties method of
    NSEntityDescription. It is only possible to edit an
    NSEntityDescription if you are not associated with a persistent store
    coordinator, so be careful. You might want to just add a custom method
    to the class of your Core Data model to execute the fetch request and
    get the job done.

    Omar Qazi
    Hello, Galaxy!
    1.310.294.1593

    On Aug 3, 2008, at 9:49 AM, James Gregurich wrote:

    > greetings!
    >
    >
    > I'm trying to figure out how to dynamically (in code) set up a
    > fetched property with a Coredata in-memory store. The documentation
    > is not detailed enough for me to quite see what the correct way to
    > set the code up is and I'm not finding much in the way of useful
    > sample code when searching on NSFetchedPropertyDescription.
    >
    > What is the correct way to programmatically add a fetched property
    > to the box  to get the list of stories for a given box managed object?
    >
    >
    >
    > thanks,
    > James Gregurich
    > Engineering Manager
    > Markzware
  • thanks for the response. Adding the property is straight forward. The
    key parts that are not clear to me are:

    1) how exactly do you set up a predicate to walk an extra entity to
    get to the target entity.

    2) how do you specify the destination entity. pass it to
    [NSFetchRequest setEntity:] and pass that fetch request to
    [NSFetchedPropertyDescription setFetchRequest:]? I would assume in my
    example that my destination entity is the story.

    -James Gregurich
    Engineering Manager
    Markzware

    On Aug 3, 2008, at 10:37 AM, Omar Qazi wrote:

    > Create an NSFetechedPropertyDescription by setting up a fetch
    > request in code, then add the property using the setProperties
    > method of NSEntityDescription. It is only possible to edit an
    > NSEntityDescription if you are not associated with a persistent
    > store coordinator, so be careful. You might want to just add a
    > custom method to the class of your Core Data model to execute the
    > fetch request and get the job done.
    >
    > Omar Qazi
    > Hello, Galaxy!
    > 1.310.294.1593
    >
    > On Aug 3, 2008, at 9:49 AM, James Gregurich wrote:
    >
    >> greetings!
    >>
    >>
    >> I'm trying to figure out how to dynamically (in code) set up a
    >> fetched property with a Coredata in-memory store. The documentation
    >> is not detailed enough for me to quite see what the correct way to
    >> set the code up is and I'm not finding much in the way of useful
    >> sample code when searching on NSFetchedPropertyDescription.
    >>
    >> What is the correct way to programmatically add a fetched property
    >> to the box  to get the list of stories for a given box managed
    >> object?
    >>
    >>
    >>
    >> thanks,
    >> James Gregurich
    >> Engineering Manager
    >> Markzware
    >
  • Am Mo,04.08.2008 um 00:19 schrieb James Gregurich:

    >
    > thanks for the response. Adding the property is straight forward.
    > The key parts that are not clear to me are:
    >
    > 1) how exactly do you set up a predicate to walk an extra entity to
    > get to the target entity.
    Loook at the documentation of NSPredicate
    You do not "set the target entity" as a preidate. A predicate is
    something liike a pattern, i.e. "color = blue". This can apply to the
    entity cars and to to the entity jeans.

    The fetch request gets the entity, to whom the predicate is applied.

    > 2) how do you specify the destination entity. pass it to
    > [NSFetchRequest setEntity:] and pass that fetch request to
    > [NSFetchedPropertyDescription setFetchRequest:]? I would assume in
    > my example that my destination entity is the story.
    NSEntityDescrition* entity = [NSEntityDescription
    entiityForName:@"story" inManagedObjectContext:/*you know*/];

    Cheers
    >
    >
    >
    >
    > -James Gregurich
    > Engineering Manager
    > Markzware
    >
    >
    > On Aug 3, 2008, at 10:37 AM, Omar Qazi wrote:
    >
    >> Create an NSFetechedPropertyDescription by setting up a fetch
    >> request in code, then add the property using the setProperties
    >> method of NSEntityDescription. It is only possible to edit an
    >> NSEntityDescription if you are not associated with a persistent
    >> store coordinator, so be careful. You might want to just add a
    >> custom method to the class of your Core Data model to execute the
    >> fetch request and get the job done.
    >>
    >> Omar Qazi
    >> Hello, Galaxy!
    >> 1.310.294.1593
    >>
    >> On Aug 3, 2008, at 9:49 AM, James Gregurich wrote:
    >>
    >>> greetings!
    >>>
    >>>
    >>> I'm trying to figure out how to dynamically (in code) set up a
    >>> fetched property with a Coredata in-memory store. The
    >>> documentation is not detailed enough for me to quite see what the
    >>> correct way to set the code up is and I'm not finding much in the
    >>> way of useful sample code when searching on
    >>> NSFetchedPropertyDescription.
    >>>
    >>> What is the correct way to programmatically add a fetched property
    >>> to the box  to get the list of stories for a given box managed
    >>> object?
    >>>
    >>>
    >>>
    >>> thanks,
    >>> James Gregurich
    >>> Engineering Manager
    >>> Markzware
    >>


    Amin Negm-Awad
    <negm-awad...>
previous month july 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today