Problem creating BNRHypnosisViewController


#1

Hey everybody, hope you are having a great day. I am currently starting chapter 6 of the book and I am encountering an issue and I can’t find the problem. I create the HypnoNerd project, drag the BNRHypnosisView.h and .m, but when I create the new file for the BNRHypnosisViewController, as soon as I change the superclass from NSObject to UIViewController I get these error messages:

"Class “LBAHypnosisViewController” defined without specifying a base class"
and

"Cannot find interface declaration for “UIViewController”, superclass of “LBAHypnosisViewController”. "

Could this be because I am using Xcode 6?I did it all over again and I get the same error.

Here is my code, it says :“add a superclass to fix this problem” but even if I do, still doesnt work. :

#import <Foundation/Foundation.h>

@interface LBAHypnosisViewController : UIViewController

@end

Thanks everybody, have a great day!

Charles


#2

Assuming the code shown is in LBAHypnosisViewController.h (not .m), it’s fine; the issue is elsewhere.

Have you been using Xcode 6 for the prior chapters as well, or did you switch beginning only with chapter 6?


#3

Hey everyone. Yes I did use xcode 6 for previous chapters. Apparently the problem came from not importing the #import , as soon as I did that, no more issues!


#4

Very interesting; thanks for the tip!


#5

It actually needs to be #import <UIKit/UIKit.h> as Foundation doesn’t include UIViewController.


#6

shall be #import < UIKit/UIKit.h >
not #import < Foundation/Foundation.h >