2010-02-18 62 views
1

我刚刚通过使用类转发解决了循环依赖问题。现在,我收到了没有找到'showSumDetails'方法的警告。我不明白为什么它应该发生,任何帮助将不胜感激。包括位的代码在这里:iPhone:MKAnnotation循环导入中的警告:找不到方法

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 - 其中该方法实际存在,并且它在头文件所定义的好。

@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 

但MyAnnotation.m下面的方法无法找到上述:-(

@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?? 
    } 

的方法,我会很乐意提供任何更多的信息。请帮助!

+2

您是否在'MyAnnotation.m'文件中导入了'MyMapViewController.h'? – Vladimir 2010-02-18 15:30:19

+0

我以为@class MyMapViewController;在MyAnnotation.h中就足够了。谢谢 - 这将删除警告,但它仍然没有达到showSumDetails方法。 – UVT 2010-02-18 16:13:24

+0

我的意思是showSumDetails() – UVT 2010-02-18 16:14:03

回答

1

你有没有导入MyMapViewController.h在MyAnnotation.m?

由于您使用的MyMapViewController正向参考MyAnnotation.h需要在MyAnnotation.m进口MyMapViewController.h 。

+0

谢谢我现在所做的,并删除警告,但它仍然没有达到showSumDetails方法。 – UVT 2010-02-18 16:16:42