开发者

iPhone: Warning in Cyclic import in MKAnnotation: method not found

I just resolved a cyclic dependency problem by using class forwarding. Now, I am getting a warning of no 'showSumDetails' method found. I don't understand why it should happen at all, any help will be appreciated. Including a bit of code here:

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 - where the method actually exists, and it is defined in the header file as well.

 @implementation MyMapViewController

    @synthesize anno开发者_JAVA百科t; 

    -(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

But the following method in MyAnnotation.m can't find the method above :-(

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

I'd be glad to provide any more info. Please help!!!


Did you import MyMapViewController.h in MyAnnotation.m?

Since you're using a forward reference for MyMapViewController in MyAnnotation.h you need to import MyMapViewController.h in MyAnnotation.m.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜