English 中文(简体)
RESTkit 法典 1001 无法找到关键词:“
原标题:RESTkit Code 1001 could not find object for keyPath: " "

Thanks in advance for all your help community!! i had a early problem which was pointed out to me and i fixed "[Person object]-should be-->[Person alloc]init]i fixed that and now able to add a Person object now to my server. But here is the problem all the values on server are null and its throwing back a 1001 code Code=1001 "Could not find an object mapping for keyPath: " UserInfo=0x5938ce0 {=RKObjectMapperKeyPath, NSLocalizedDescription=Could not find an object mapping for keyPath: } what am i mapping wrong any ideas? Noobie here and be grateful for any help provided! Ohh yea am willing to pay for lessons on this matter if your in socal. Thnx again!

RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[Person class]];
 [userMapping mapKeyPath:@"updated_at" toAttribute:@"updatedAt"];
[userMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"];
[userMapping mapKeyPath:@"name" toAttribute:@"name"]; 
[userMapping mapKeyPath:@"id" toAttribute:@"personId"];

RKObjectMapping* dogMapping = [RKObjectMapping mappingForClass:[Dog class]];
[dogMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"]; 
[dogMapping mapKeyPath:@"person_id" toAttribute:@"spersonId"]; 
[dogMapping mapKeyPath:@"name" toAttribute:@"name"]; 
[dogMapping mapKeyPath:@"updated_at" toAttribute:@"updatedAt"]; 
[dogMapping mapKeyPath:@"id" toAttribute:@"dogId"]; 

RKObjectMapping *dataMapping = [RKObjectMapping mappingForClass:[Data class]]; 
[dataMapping mapKeyPath:@"dog" toAttribute:@"dogs"]; 
[dataMapping mapKeyPath:@"person" toRelationship:@"person" withMapping:userMapping]; 
[[RKObjectManager sharedManager].mappingProvider addObjectMapping:dataMapping]; 

[[RKObjectManager sharedManager].mappingProvider setMapping:userMapping 
forKeyPath:@"people"];

RKObjectRouter * router = [RKObjectManager sharedManager].router;
[router routeClass: [Person class] toResourcePath:@"/people/:personId"];
[router routeClass: [Person class] toResourcePath:@"/people" 
forMethod:RKRequestMethodPOST];

RKObjectMapping *personSerializationMapping= [RKObjectMapping mappingForClass:
[NSMutableDictionary class]];
[personSerializationMapping mapAttributes:@"name", nil];
[[RKObjectManager sharedManager].mappingProvider 
setSerializationMapping:personSerializationMapping forClass: [Person class]];

Person* daveLiu =[[[Person alloc]init]autorelease];
daveLiu.name = @"dave";
[[RKObjectManager sharedManager] postObject:daveLiu  delegate:self];
问题回答

我的服务器上的所有物体都是“匿名”的,我对RethKit无法找到正确的地图也存在同样的问题。 我确定的方式是使用物体管理方法,让我包括制图:

[objectManager postObject:object mapResponseWith:[object objectMapping] delegate:self];
[objectManager loadObjectsAtResourcePath:path objectMapping:mapping delegate:self];

现在,我的所有合同都来自服务器,如:

{
    "Id": "12345678-1234-1234-1234-1234567890ab",
    "Type": "SURVEY",
    "Code": "1234",
    "Description": "blah blah blah",
    "Message": "blah blah blah",
    "Url": "http://nowhere.com/",
    "NextAttemptHours": 4
}

可绘制成正确目标。 它为随时提供物体勘测做了额外工作,但这项工作确实如此。 我这样做的办法是,在我的物体上采用一种分类方法,以归还使事情非常干净和可以理解的适当物体。





相关问题
Issue with compiling example code

I m trying to compile this sample code with XCode 4.2b, here s how my project looks like: Application type: Command Line Tool. When I m trying to build the project, I get the following list of errors:...

Storyboard Partial Cut remove

With the new xCode Storyboard function it is posible to switch the view with some prepared switch-modes like: Style: "Model" Transition: "Partial Cut" So I have tried to use the "Partial Cut", but ...

Xcode 4.2: What is the most effective method switching views?

I was thinking of games in particular, where there may be alot of views that need to be switched in and out. Could someone supply some sample xcode 4.2 code? Many tutorials have old xcode versions ...

热门标签