godman godman - 3 years ago 111
Objective-C Question

New view controller in xcode?

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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download