Start a new topic

Some related objects not fetched with query

I'm querying a collection whose entities each include two attributes that are KinveyRefs. I've implemented the KCSPersistable class's `kinveyPropertyToCollectionMapping` method with the correct backend attribute and collection names. It looks like this (actually, the class is much larger, but these are the relevant parts):


class Session: NSObject {
    /// The parent who requested the session
    var parent: Parent?

    /// The coach who was requested for the session
    var coach: Coach?

    // Other properties...

    override static func kinveyPropertyToCollectionMapping() -> [NSObject : AnyObject]! {
            return [
                "parent": "Parents"
                "coach": "Coaches"

    // Other methods...

 When I make my `KCSLinkedAppData` query, the session is returned, and both the `parent` and `coach` property are set. However, the `coach` object is usually corrupt. When my app attempts to access it, the app crashes with EXC_BAD_ACCESS. If I set a break point in `queryWithQuery`'s completion handler, I can see that the coach's properties are all either `nil` or `unable to read data`.

Occasionally, the `coach` is set properly, but it only works intermittently. The `coach` is significantly larger than the `parent`. The intermittent nature of the problem, combined with the difference in size between the `parent` and `coach` entities leads me to suspect that `queryWithQuery` is calling the completion block before the `coach` is properly set.

I read the section of the Data Store Guide about the limitations of Kinvey's relational data features, but I don't think any of them apply to this situation. Does anyone have any suggestions about what I might be doing wrong? Or is this a bug in KinveyKit?

Login or Signup to post a comment