开发者

Objective C Properties

I tried searching for this issue, but can't seem to find out what I'm doing wrong.

Here is my controller header:

#import <UIKit/UIKit.h>

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

- (IBAction)setNewImage;

@end

Here is my controller class:

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

@implementation BabyLearnViewContro开发者_运维问答ller

@synthesize btnImage;
@synthesize myMediaManager;

I am getting the errors:

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

Any ideas? Usually the 1st error comes up if you have a cylical reference. 'MediaManager' doesn't reference anything else. Any ideas?


Since you have no mentions of MediaManager class at the moment it is used in header file compiler can't figure out what "MediaManager" is and issues an error. Declare that class using forward declaration in your header file to let compiler know that MediaManager is actually a class:

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

P.S. As an alternative you can import MediaManager.h in your header, but using forward declaration is preferred.


Place #import "MediaManager.h" this in header file of BabyLearnViewController


try add @class MediaManager; before @interface

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜