0

Here is my original question for adding a new view controller in xcode;

Adding a View Controller in Xcode?

This is the code I observed, that loads out in a new project in Xcode for a view controller.h/m file

.h

@interface ViewController : UIViewController

{


}

@end

.m

@interface ViewController ()

@end

@implementation ViewController

But when I add a new class; I notice there is no 'UIViewController' object but instead there is an NSOBject.

.h

@interface Newclass : NSObject
@end

.m

@implementation Newclass
@end

My question; to successfully programmatically access a new view controller in x code story board, do your new custom .m/.h files have to be formatted as a UIViewController or does it matter.

1 Answer 1

1

Yes, to inherit the properties & methods a UIViewController needs it must be 'formatted' as (the correct term is 'inherit from') a UIViewController. So:

@interface Newclass : UIViewController
@end

and

@implementation Newclass
@end
1
  • why isn't UIViewController used instead of nsobject for new classes
    – godman
    Oct 3, 2014 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.