Reputation: 25711
I have a subclassed UIView
called TestView.h
below:
#import <UIKit/UIKit.h>
#import "TestsViewController.h"
@interface TestView : UIView
// To get the navigation controller parent clas
@property (nonatomic, retain) TestsViewController *parent;
Line above causes error: Unknown type name TestViewController: did you mean CostViewController
- (id) initWithFrame:(CGRect)frame andObjects:(PFObject *)objects;
@end
And I have the TestsViewController.h
below:
#import "CostViewController.h"
#import "TesView.h"
@interface TestsViewController : UIViewController <UITextViewDelegate, CostViewControllerDelegate, UIScrollViewDelegate>
@end
And in the implementation file I have for TestsViewController.m
I call this:
TestView *tests = [[TestView alloc] initWithFrame:frame andObjects:replies];
tests.parent = self;
But the line above gives an error:
Incompatiable pointer types assigning to CostsViewController * from TestsViewController *
What is wrong with this?
CostViewController.h
is:
#import <UIKit/UIKit.h>
#include <stdlib.h>
@class CostViewController;
@protocol CostViewControllerDelegate <NSObject>
// Functions for delegate
@end
@interface CostViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextViewDelegate, MBProgressHUDDelegate>
{
MBProgressHUD *HUD;
MBProgressHUD *refreshHUD;
}
@property (nonatomic, weak) id <CostViewControllerDelegate> delegate;
@end
Thanks.
Upvotes: 1
Views: 2284
Reputation: 159
This may be due to circular Import. Replace #import "TestsViewController.h" with @class TestsViewController
Upvotes: 4
Reputation: 6263
Seems like you have typo in your code.
@property (nonatomic, retain) TestsViewController
and
Unknown type name TestViewController:
What is your class name? Test or Tests ? And the same situation with other class
@interface CostViewController
and
Incompatiable pointer types assigning to CostsViewController
Upvotes: 0
Reputation: 2654
Instead of below code you may used loadView method in TestsViewController.m -
TestView *tests = [[TestView alloc] initWithFrame:frame andObjects:replies];
tests.parent = self;
-(void)loadView
{
self.view= [[TestView alloc] initWithFrame:frame andObjects:replies];
}
Hope this help !
Upvotes: 0