2010-02-18 5 views
1

Je viens de résoudre un problème de dépendance cyclique en utilisant le transfert de classe. Maintenant, je reçois un avertissement de ne pas trouver de méthode 'showSumDetails'. Je ne comprends pas pourquoi cela devrait arriver, toute aide sera appréciée. Y compris un peu de code ici:iPhone: Avertissement dans l'importation cyclique dans MKAnnotation: méthode non trouvée

MyAnnotation.h

#import <Foundation/Foundation.h> 
#import <MapKit/MapKit.h> 
//#import "MyMapViewController.h" obviously this wasn't possible :-(
@class MyMapViewController; 

@interface MyAnnotation : NSObject<MKAnnotation> { 


    MyMapViewController* mapController; 
} 

MyMapViewController.h

#import <UIKit/UIKit.h> 
#import <MapKit/MapKit.h> 
#import <MapKit/MKReverseGeocoder.h> 
#import "MyAnnotation.h" 

@interface MyMapViewController : UIViewController <MKMapViewDelegate>{ 

    MyAnnotation *annot; 
} 

MyMapViewController.m - où la méthode existe effectivement, et il est défini dans le fichier d'en-tête comme bien.

@implementation MyMapViewController 

    @synthesize annot; 

    -(void) showSumDetails:(id)aSumData{ 
    NSLog(@"mapViewController-showSumDetails"); 
    SumDetailsViewController *wrController = [[SumDetailsViewController alloc] init]; 
    wrController.sumData = aSumData; 
    [self.navigationController pushViewController:wrController animated:YES];//This needs to be pushed 
    [wrController release]; 
} 
@end 

Mais la méthode suivante dans MyAnnotation.m ne peut pas trouver la méthode ci-dessus :-(

@implementation MyAnnotation 

@synthesize sumData; 
@synthesize mapController;  

- (void) showPD{//is also defined in header file 
     NSLog(@"sPD - MyAnn"); 

     [mapController showSumDetails:sumData]; //This doesn't have a clue about showSumDetails method- Why?? 
    } 

Je serais heureux de fournir plus d'informations. S'il vous plaît aider !!!

+2

Avez-vous importé 'MyMapViewController.h' dans le fichier' MyAnnotation.m'? – Vladimir

+0

Je pensais @class MyMapViewController; dans MyAnnotation.h est suffisant. Merci - cela supprime l'avertissement mais n'atteint toujours pas la méthode showSumDetails. – UVT

+0

Je voulais dire showSumDetails() – UVT

Répondre

1

avez-vous importer MyMapViewController.h dans MyAnnotation.m?

Puisque vous utilisez une référence en avant pour MyMapViewController en MyAnnotation.h vous devez importer MyMapViewController.h dans MyAnnotation.m .

+0

Merci j'ai fait maintenant et cela supprime l'avertissement mais il n'atteint toujours pas la méthode showSumDetails. – UVT

Questions connexes