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

后端 未结 2 1013
南笙
南笙 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: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.

提交回复
热议问题