My program was running fine, but I changed something and now it has over 48 errors.
I think I know the problem, but I don't know how to fix it. I created a class called mViewBase
for all my UIViewController
s to derive from.
I decided to have a navigtion bar at the bottom of all my views, to go to other view controllers called cakes2
. So cakes2.h imports mViewBase
, and mViewBase
import cakes2.h
You must be able to do this in Objective-C. Does anybody have any idea of what I can do?
My mViewBase.h file:
#import <UIKit/UIKit.h>
#import "Cakes2.h"
@interface mViewBase : UIViewController {
UIView *mBackground;
UIView *mBackArrow;
UITextView *mTitle;
// Cakes2 *mCakes;
}
-(void) aSetTitle: (NSString *) NewTitle;
-(IBAction) aBack: (id) tender;
-(IBAction) aHome: (id) sender;
-(IBAction) aCakes: (id) sender;
-(IBAction) aCall: (id) sender;
-(IBAction) aDirections: (id) sender;
@end
My Cakes2.h file:
#import <UIKit/UIKit.h>
#import "Gallery.h"
#import "WebView.h"
#import "mViewBase.h" // Circular reference! But I need it
@interface Cakes2 : mViewBase <UITableViewDelegate, UITableViewDataSource> {
// Gallery *mGallery;
IBOutlet UITableView *mMenu;
// WebView *mWebView;
}
-(IBAction) aOpenWeb;
@end
You can use a forward declaration in one of your header files to avoid the need to import the other header. For example, in mViewBase.h, you can say:
@class Cakes2;
Now the compiler knows that "Cakes2" refers to a class, and you don't need to import the entire Cakes2.h file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With