RKObjectMappingを使用してオブジェクトマッピングを実行しようとしています。
これが私のJSONのサンプルです:
{
"notification": {
"created_at": "2012-10-23T02:43:43-04:00",
"delivered": true,
"id": 3915,
"missed": false,
"rejected": false,
"search_request_id": 360,
"bid": {
"bid_type": "none",
"bid_type_values": null,
"comment": "hi\n",
"created_at": "2012-10-23T02:43:54-04:00",
"delivered": true,
"delivery_type": "email",
"id": 268,
"has_chat_session": true,
},
"search_request": {
"created_at": "2012-10-23T02:43:42-04:00",
"customer_id": 6,
"id": 360,
"latitude": "40.7536854",
"location": "10001",
"longitude": "-73.9991637",
}
}
jsonlintを使用してJSONを検証しましたが、有効です。
これが私のマッピングです。
RKObjectMapping *bidMapping = [RKObjectMapping mappingForClass:[Bid class]];
[bidMapping mapKeyPath:@"comment" toAttribute:@"comment"];
[bidMapping mapKeyPath:@"chat_session_id" toAttribute:@"chatSessionId"];
[objectManager.mappingProvider setMapping:bidMapping forKeyPath:@"bid"];
RKObjectMapping *searchRequestMapping = [RKObjectMapping mappingForClass:[SearchRequest class]];
[searchRequestMapping mapKeyPath:@"purpose" toAttribute:@"purpose"];
[searchRequestMapping mapKeyPath:@"customer_Id" toAttribute:@"customerId"];
[searchRequestMapping mapKeyPath:@"need" toAttribute:@"need"];
[objectManager.mappingProvider setMapping:searchRequestMapping forKeyPath:@"search_request"];
RKObjectMapping *notificationMapping = [RKObjectMapping mappingForClass:[Notification class]]; // have not mapped all the attributes.
[notificationMapping mapKeyPath:@"id" toAttribute: @"notificationId"];
[notificationMapping mapKeyPath:@"created_at" toAttribute:@"timestamp"];
[notificationMapping mapKeyPath:@"vendor_id" toAttribute:@"vendorId"];
[notificationMapping mapKeyPath:@"bid" toRelationship:@"bid" withMapping:bidMapping];
[notificationMapping mapKeyPath:@"search_request" toRelationship:@"search_request" withMapping:notificationMapping];
[objectManager.mappingProvider setMapping:notificationMapping forKeyPath:@"notification"];
loadObjectsAtResourcePathを実行しようとすると、デバッグできないアサーションエラーでプログラムがクラッシュします。rootKeyPathsも使用してみましたが、役に立ちませんでした。
誰かが私がエラーを見つけるのを手伝ってもらえますか?
ありがとう!
ps:NSDictionaryパラメーターを追加したいのですが、ドキュメントには、appendQueryParams:paramsを使用すると書かれています。しかし、非推奨であるという警告が表示されます。私が使用できる代替案はありますか?