RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class

后端 未结 2 987
南笙
南笙 2021-01-04 00:30

I ran into a new problem that I can\'t seem to find a way around... Here is my RestKit code, following the Twitter Core Data example:

//
// RESTKIT
//

// re         


        
相关标签:
2条回答
  • 2021-01-04 00:53

    Have now read class documentation for RKObjectManager which clarifies handling of AF networking handling of base url. If I had read this first would have saved myself some time, and also from making irrelevant comments regarding paths in RestKit examples.

    Had problems matching a mix of object and entity mappings including a number of object mappings with a nil key path and different URL and found this answer very useful for determining the cause of the problem described following which may have contributed to others experiencing similar problems.

    0 讨论(0)
  • 2021-01-04 00:57

    This indicates that an attempt was made to create an object without calling the appropriate Core Data initializer, which probably means that you are getting an RKObjectRequestOperation instance instead of an RKManagedObjectRequestOperation.

    I suspect that the response descriptor is failing to match against the URL, which is causing it to select the wrong object request operation type. You can check this by putting a breakpoint in appropriateObjectRequestOperationWithObject:method:path:parameters: at the lines that read:

    NSArray *matchingDescriptors = RKFilteredArrayOfResponseDescriptorsMatchingPath(self.responseDescriptors, requestPath);
    BOOL containsEntityMapping = RKDoesArrayOfResponseDescriptorsContainEntityMapping(matchingDescriptors);
    BOOL isManagedObjectRequestOperation = (containsEntityMapping || [object isKindOfClass:[NSManagedObject class]]);
    

    This logic is what's responsible for selecting the type of operation created. Check that the matchingDescriptors contains the response descriptor you are expecting and then check the values of the next two booleans. My guess is that RKFilteredArrayOfResponseDescriptorsMatchingPath is not returning what you expect.

    0 讨论(0)
提交回复
热议问题