1

I'm setting up a base view controller called "BHAccountBaseViewController" and two other views that inherit from some basic functionality from the base controller.

  1. "BHAccountBaseViewController" Inherits from "UIViewController"
  2. "BHAccountViewController" (implements UITextFieldDelegate) and Inherits from "BHAccountBaseViewController"
  3. Lastly I have one recently created class that I called "BHCreateProfileViewController" every time that I just simply include #import directive to "BHAccountBaseViewController" to inherit from this class Xcode fails to compile due to APPLE MACH-O LINKER ERROR!

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thoughts? these are my three header files

BHAccountBaseViewController

#import <UIKit/UIKit.h>
#import "BHFileManager.h"

@interface BHAccountBaseViewController : UIViewController
@end

BHAccountViewController

#import "BHAccountBaseViewController.h"
@interface BHAccountViewController : BHAccountBaseViewController<UITextFieldDelegate>
@end

BHCreateProfileViewController

#import "BHAccountBaseViewController.m"
@interface BHCreateProfileViewController : UIViewController <UITextFieldDelegate>
@property (strong, nonatomic) id user;
@end

if I comment out the import on the last file the linker error goes a way! but I want to be able to inherit from my base clase ... thoughts?

Help would be much appreciated!

3 Answers3

1

In implementation of BHCreateProfileViewController given above, I found the code looks like getting wrong at first line. What about fixing it as following:

#import "BHAccountBaseViewController.m"

to

#import "BHAccountBaseViewController.h"

and I wonder why BHCreateProfileViewController comes to inherit from UIViewController not BHAccountBaseViewController. Could you explain that?

Kyokook Hwang
  • 2,682
  • 21
  • 36
1

This might be due to the retain cycle deadlock problem. You have to use forward class declaration for this i.e you can try @Class instead of #import. Please refer to these limks :

Objective-C: Forward Class Declaration

@class vs. #import

These might help.

Community
  • 1
  • 1
0

In the compilation time your compiler would actually look for your interface files instead of implementation file.Compiler does not bother even if .m file is not available. So while importing you are supposed to import .h instead .m.

Rajesh
  • 10,318
  • 16
  • 44
  • 64