我尝试搜索此问题,但似乎无法找出我在做什么。

这是我的控制器标头:

#import <UIKit/UIKit.h>

@interface BabyLearnViewController : UIViewController {
    UIButton *btnImage;
    MediaManager* myMediaManager;
}
@property (nonatomic, retain) IBOutlet UIButton *btnImage;
@property (retain) MediaManager* myMediaManager;

- (IBAction)setNewImage;

@end


这是我的控制器类:

#import "BabyLearnViewController.h"
#import "MediaManager.h";

@implementation BabyLearnViewController

@synthesize btnImage;
@synthesize myMediaManager;


我收到错误:

error: expected specifier-qualifier-list before 'MediaManager'
error: no declaration of property 'myMediaManager' found in the interface


有任何想法吗?如果有圆柱参考,通常会出现第一个错误。 “ MediaManager”未引用其他任何内容。有任何想法吗?

最佳答案

由于您现在没有提到MediaManager类,因此在头文件编译器中使用它时,无法确定“ MediaManager”是什么,并发出错误。使用头文件中的前向声明声明该类,以使编译器知道MediaManager实际上是一个类:

@class MediaManager;
@interface BabyLearnViewController : UIViewController {
   ...


附言或者,您可以在标头中导入MediaManager.h,但最好使用前向声明。

10-08 16:26