[PROJET] - 2 relations nappées avec RestKit

Bonjour,



Voilà  pour mon projet j'utilise RestKit avec des services Restful. Lorsque je mappe une entité sans relation, aucun problème.



Par contre, maintenant je cherche à  recevoir une entité qui a une relation. je vous mets mon code ci-dessous:
<br />
//<br />
//  ViewControllerData.m<br />
//  culturalnetwork<br />
//<br />
//  Created by Adrienne Villar on 31.07.12.<br />
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.<br />
//<br />
#import &quot;ViewControllerData.h&quot;<br />
#import &quot;Data.h&quot;<br />
#import &quot;CompositeCard.h&quot;<br />
@interface ViewControllerData ()<br />
@end<br />
@implementation ViewControllerData<br />
<br />
- (void)loadTimeline {<br />
    // Charger le modèle via RestKit<br />
    RKObjectManager* objectManager = [RKObjectManager sharedManager];<br />
    objectManager.client.baseURL = [RKURL URLWithString:@&quot;http://localhost:8080/CulturalNetworksMuseumServer/resources&quot;];<br />
    [objectManager loadObjectsAtResourcePath:@&quot;/artifactcards&quot; delegate:self];<br />
}<br />
<br />
- (void)viewDidLoad<br />
{<br />
    [super viewDidLoad];<br />
   <br />
<br />
    RKLogConfigureByName(&quot;RestKit/Network*&quot;, RKLogLevelTrace);<br />
    RKLogConfigureByName(&quot;RestKit/ObjectMapping&quot;, RKLogLevelTrace);<br />
   <br />
    // Initialisation de RestKit<br />
    RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@&quot;http://localhost:8080/CulturalNetworksMuseumServer/resources&quot;];<br />
   <br />
    // Active la gestion automatique de l&#39;indicateur de l&#39;activité réseau<br />
    objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;<br />
   <br />
    //Configuration du mappage de l&#39;objet CompositeCard<br />
    RKObjectMapping* compositeMapping = [RKObjectMapping mappingForClass:[CompositeCard class]];<br />
    [compositeMapping mapKeyPath:@&quot;id&quot; toAttribute:@&quot;cc_id&quot;];<br />
    [compositeMapping mapKeyPath:@&quot;name&quot; toAttribute:@&quot;cc_name&quot;]; <br />
   <br />
    //[[objectManager mappingProvider] setObjectMapping:compositeMapping forKeyPath:@&quot;/compositecards&quot;];<br />
   <br />
    //Configuration du mappage de l&#39;objet Data<br />
    RKObjectMapping * dataMapping = [RKObjectMapping mappingForClass:[Data class]];<br />
    [dataMapping mapKeyPath:@&quot;id&quot; toAttribute:@&quot;ac_id&quot;];<br />
    [dataMapping mapKeyPath:@&quot;file&quot; toAttribute:@&quot;ac_file&quot;];<br />
    [dataMapping mapKeyPath:@&quot;typefile&quot; toAttribute:@&quot;ac_typefile&quot;];<br />
    [dataMapping mapKeyPath:@&quot;author&quot; toAttribute:@&quot;ac_author&quot;];<br />
    [dataMapping mapKeyPath:@&quot;title_topic&quot; toAttribute:@&quot;ac_title_topic&quot;];<br />
    [dataMapping mapKeyPath:@&quot;year&quot; toAttribute:@&quot;ac_year&quot;];<br />
    [dataMapping mapKeyPath:@&quot;technical&quot; toAttribute:@&quot;ac_technical&quot;];<br />
    [dataMapping mapKeyPath:@&quot;support_media&quot; toAttribute:@&quot;ac_support_media&quot;];<br />
    [dataMapping mapKeyPath:@&quot;format&quot; toAttribute:@&quot;ac_format&quot;];<br />
    [dataMapping mapKeyPath:@&quot;owner&quot; toAttribute:@&quot;ac_owner&quot;];<br />
    [dataMapping mapKeyPath:@&quot;collection&quot; toAttribute:@&quot;ac_collection&quot;];<br />
    [dataMapping mapKeyPath:@&quot;descritpion_remarks&quot; toAttribute:@&quot;ac_descritpion_remarks&quot;];<br />
    [dataMapping mapKeyPath:@&quot;compositeCard&quot; toRelationship:@&quot;ac_compositeCard&quot; withMapping:compositeMapping];<br />
   <br />
   <br />
    // Permet de mapper l&#39;objet artifactCard avec la source de ce dernier<br />
    [objectManager.mappingProvider setObjectMapping:dataMapping forResourcePathPattern:@&quot;/artifactcards&quot;];<br />
    //[[objectManager mappingProvider] addObjectMapping:dataMapping];<br />
   <br />
    NSString * test = @&quot;Mappage dans la View Controller&quot;;<br />
    NSLog(@&quot;%@&quot;,test);<br />
   <br />
    // appel de la fonction qui charge le modèle<br />
    [self loadTimeline];<br />
}<br />
#pragma mark RKObjectLoaderDelegate methods<br />
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response<br />
{<br />
    NSLog(@&quot;Loaded payload: %@&quot;, [response bodyAsString]);<br />
} <br />
/**<br />
** Permet de charger la liste des adresses provenant des services Rest sous forme de tableau<br />
** Remplir le tableau _addresses (local) avec le tableau d&#39;objects<br />
** Mettre à  jour la TableView<br />
**/<br />
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {<br />
    NSLog(@&quot;Load collection of ArtifactCards: %@&quot;, objects);<br />
    _data = [NSArray arrayWithArray:objects];<br />
    [_tableView reloadData];<br />
}<br />
- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {<br />
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@&quot;Error&quot; message:[error localizedDescription] delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];<br />
    [alert show];<br />
    NSLog(@&quot;Hit error: %@&quot;, error);<br />
}<br />
- (void)viewDidUnload<br />
{<br />
    [super viewDidUnload];<br />
    // Release any retained subviews of the main view.<br />
}<br />
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation<br />
{<br />
    return (interfaceOrientation == UIInterfaceOrientationPortrait);<br />
}<br />
@end<br />




est-ce que quelqu'un peut m'aider?

Merci d'avance
Connectez-vous ou Inscrivez-vous pour répondre.