1

我刚刚通过使用类转发解决了循环依赖问题。现在,我收到未找到“showSumDetails”方法的警告。我不明白为什么会发生这种情况,任何帮助将不胜感激。在这里包括一些代码:

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

我很乐意提供更多信息。请帮忙!!!

4

1 回答 1

1

您是否在 MyAnnotation.m 中导入了 MyMapViewController.h?

由于您在 MyAnnotation.h 中使用 MyMapViewController 的前向引用,因此您需要在 MyAnnotation.m 中导入 MyMapViewController.h。

于 2010-02-18T15:34:19.083 回答