RestKit不会将recursionJSON映射到对象

编辑2由于我不明白的原因,将响应描述符直接添加到httpsRKManager,而不是应用程序分层,让RK识别“响应”响应描述符。 现在的问题是,似乎没有认识到“ErrorStatus”/结束编辑的属性映射

我有三个问题。 First Shops和recursion对象Shop不会显示为LLSResult对象的一部分。 其次这些对象不是从结果中填充的,第三,是否有办法完全跳过商店。 上下文是我正在将现有的应用程序从Ruby服务器迁移到具有不同api的.NET服务器。 复合事项。 两个星期前我从来没有碰过Mac。 更不用说任何生态系统了。

编辑2:响应描述符修复

NSString *path = [[ConfigManager sharedInstance] getEventsURL]; [[[AppCore sharedInstance] httpsRKManager]addResponseDescriptor: [RKResponseDescriptor responseDescriptorWithMapping:[LLSResponse jsonMapping] method:RKRequestMethodAny pathPattern:path keyPath:@"Response" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]]; // This didn work //[BaseRO addResponseDescriptorForPathPattern: [[ConfigManager sharedInstance] getEventsURL] // withMapping:[LLSResponse jsonMapping]]; 

编辑2的日志:


         }用对象映射来对象(null)
     2015-12-11 10:19:24.805 Clymb [5234:149794] D restkit.object_mapping:RKPropertyInspector.m:131对'LLSResponse'类进行caching属性检查:{
         debugDescription = {
             isPrimitive = 0;
             keyValueCodingClass = NSString;
             name = debugDescription;
         };
         description = {
             isPrimitive = 0;
             keyValueCodingClass = NSString;
            名称=描述;
         };
         events = {
             isPrimitive = 0;
             keyValueCodingClass = Events;
             name = events;
         };
         hash = {
             isPrimitive = 1;
             keyValueCodingClass = NSNumber;
             name = hash;
         };
        商店= {
             isPrimitive = 0;
             keyValueCodingClass =商店;
            名字=商店;
         };
        状态= {
             isPrimitive = 0;
             keyValueCodingClass = ErrorStatus;
             name = status;
         };
     }
     2015-12-11 10:19:24.805 The Clymb [5234:149797] D restkit.object_mapping:RKMappingOperation.m:592将keyPath'ErrorStatus'中的一对一关系值映射到'ErrorStatus'
     2015-12-11 10:19:24.806 The Clymb [5234:149797] T restkit.object_mapping:RKMappingOperation.m:550使用映射执行嵌套对象映射ErrorStatus> for data:{
         “@ID”=“”;
         “@Status”=确定;
     }
     2015-12-11 10:19:24.806 The Clymb [5234:149797] D restkit.object_mapping:RKMappingOperation.m:868开始映射操作...
     2015-12-11 10:19:24.807 Clymb [5234:149797] T restkit.object_mapping:RKMappingOperation.m:869执行映射操作:针对'ErrorStatus'对象。 从对象映射值{
         “@ID”=“”;
         “@Status”=确定;
     }用对象映射来对象(null)

编辑结束2

JSON

 { Response: { ErrorStatus: { @ID: "", @Status: "OK" }, Events: { Event: [ { @Title: "Test - Hero 1", @ID: "00010033005800000000", @Start: "2015-12-07 09:00:00Z", @End: "2015-12-31 08:00:00Z", @Status: "Active", @Image_Small: "http://www.leftlanesports.com/App_Themes/Default/graphics/Events/291_00010033005800000000.jpg", @Image_Large: "http://www.leftlanesports.com/App_Themes/Default/graphics/Events/447_00010033005800000000.jpg", @TypeCode: "EVTH1", Description: { #cdata-section: "yo" }, ShortDescription: { #cdata-section: "50%##Hero Event 1" } }, ... ] }, Shops: { Shop: [ { @Title: "Adventures", @ID: "00030000000000000000" }, { @Title: "Apparel", @ID: "00080000000000000000", Shop: [ { @Title: "Mens", @ID: "00080001000000000000", Shop: [ { @Title: "Accessories", @ID: "00080001003700000000", Shop: [ 

.h文件

 #import #import "BaseRO.h" #import "EventDO.h" @class LLSResponse; @class Events; @class ErrorStatus; @interface LLSResponse : NSObject @property (nonatomic, strong) ErrorStatus * status; @property (nonatomic, strong) Events * events; - getAllEvents; @end @interface ErrorStatus : NSObject @property (nonatomic, copy) NSString * _id; @property (nonatomic, copy) NSString * Status; @end @interface Events : NSObject ; @property (nonatomic, strong) NSMutableArray *events; @end @interface Shop : NSObject ; @property (nonatomic, copy) NSString * _id; @property (nonatomic, copy) NSString * title; @property (nonatomic, strong) NSMutableArray *shops; @end @interface Shops : NSObject ; @property (nonatomic, strong) NSMutableArray * shops; @end 

编辑2后的相关部分似乎是Response.jsonMapping和ErrorStatus.jsonMapping。

.m文件

 @implementation LLSResponse + (RKObjectMapping *)jsonMapping { RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace); //??? debugging RKObjectMapping * entityMapping = [RKObjectMapping mappingForClass:[LLSResponse class]]; [entityMapping addPropertyMapping: [RKRelationshipMapping relationshipMappingFromKeyPath:@"ErrorStatus" toKeyPath:@"ErrorStatus" withMapping:[ErrorStatus jsonMapping]]]; [entityMapping addPropertyMapping: [RKRelationshipMapping relationshipMappingFromKeyPath:@"Shops" toKeyPath:@"Shops" withMapping:[Shops jsonMapping]]]; [entityMapping addPropertyMapping: [RKRelationshipMapping relationshipMappingFromKeyPath:@"Events" toKeyPath:@"Events" withMapping:[Events jsonMapping]]]; return entityMapping; } - (NSArray *) getAllEvents { Events * events = self.events; NSArray *allEvents = events.events; return allEvents; } @end @implementation ErrorStatus + (RKObjectMapping *)jsonMapping { RKObjectMapping * entityMapping = [RKObjectMapping mappingForClass:[ErrorStatus class]]; [entityMapping addAttributeMappingsFromDictionary:@{ @"@ID" : @"_id", @"@Status" : @"Status" }]; return entityMapping; } @end @implementation Events + (RKObjectMapping *)jsonMapping { RKObjectMapping * entityMapping = [RKObjectMapping mappingForClass:[Events class]]; [entityMapping addPropertyMapping: [RKRelationshipMapping relationshipMappingFromKeyPath:@"Event" toKeyPath:@"Event" withMapping:[EventDO jsonMapping]]]; return entityMapping; } @end @implementation Shop + (RKObjectMapping *)jsonMapping { RKObjectMapping * entityMapping = [RKObjectMapping mappingForClass:[Shop class]]; [entityMapping addAttributeMappingsFromDictionary:@{ @"@ID" : @"_id", @"@Title" : @"title" }]; //RKEntityMapping * shopMapping = [RKEntityMapping mappingForClass: [Shop class]]; //[entityMapping addRelationshipMappingWithSourceKeyPath:@"Shop" mapping:entityMapping]; [entityMapping addPropertyMapping: [RKRelationshipMapping relationshipMappingFromKeyPath:@"Shop" toKeyPath:@"Shop" withMapping:entityMapping]]; return entityMapping; } @end @implementation Shops + (RKObjectMapping *)jsonMapping { RKObjectMapping * entityMapping = [RKObjectMapping mappingForClass:[Shops class]]; [entityMapping addPropertyMapping: [RKRelationshipMapping relationshipMappingFromKeyPath:@"Shop" toKeyPath:@"Shop" withMapping:[Shop jsonMapping]]]; return entityMapping; } @end 

当我在Xcode模拟器中运行应用程序时,发现它已经成功地调用了服务器,并返回了上面的JSON。 已经创build了LLSResponse对象,ErrorStatus对象和Events对象。 然而Shops对象没有。 所以在Shops / Shop映射中有一个问题,但是我无法看到它。 当我检查这些对象时,他们都没有被填充。 我不知道这是一个单独的问题还是商店问题的后果。

商店实际上是由API返回的无关数据。 有没有办法跳过它? 如果根本没有映射会发生什么; 这是一个错误?

编辑2:文本删除。

谢谢