私のサーバーにiPhone経由で人物クラスを追加しようとしています。RESTkitセレクタエラーが認識されない
私は、次のコードを持っていると私はこのエラーを取得:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Person object]: unrecognized selector sent to class 0x5fe6c' error
@interface Data : NSObject {
Person *person;
NSArray *dogs;
}
@property (nonatomic ,retain) Person *person;
@property (nonatomic ,retain) NSArray *dogs;
@end
@interface Person : NSObject {
NSString *name;
NSNumber *personId;
NSDate *updatedAt;
NSDate *createdAt;
}
@property (nonatomic , retain) NSDate * createdAt;
@property (nonatomic , retain) NSDate * updatedAt;
@property (nonatomic , retain) NSNumber *personId;
@property (nonatomic , retain) NSString *name;
@end
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[Person class]];
[userMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"];
[userMapping mapKeyPath:@"updated_at" toAttribute:@"updatedAt"];
[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] loadObjectsAtResourcePath:@"/people"
objectMapping:dataMapping delegate:self];
-(void)createObject{
RKObjectRouter * router = [RKObjectManager sharedManager].router;
[router routeClass: [Person class] toResourcePath:@"/people/:personId"];
[router routeClass: [Person class] toResourcePath:@"/people"
forMethod:RKRequestMethodPOST];
Data *data =[[Data alloc]init];
Person *daveLiu = [Person object];
daveLiu.name = @"Dave Liu";
[[RKObjectManager sharedManager] postObject:daveLiu delegate:self];
}
この行は何を意味していますか? Person * daveLiu = [Personオブジェクト]; alloc] init]をシャドウしないでください? – mja