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
Sign up to request clarification or add additional context in comments.

1 Comment

why isn't UIViewController used instead of nsobject for new classes

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.