I just noticed after adding a new ViewController
that it isn't a UIViewController
like the one created by Xcode. I didn't find an answer on google so I hope one of you could explain the difference between these two to me.
Edit
To clarify my question:
This is the declaration of my UIViewController
:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
And this is the declaration of my ViewController
:
#import "ViewController.h"
@interface GameViewController : ViewController
What is the difference between these two ViewControllers?
What is the difference between these two ViewControllers?
Not a great deal, but it depends on the functionality defined in ViewController
. It's fairly common to create a base class that contains common functionality you want in all derived classes, and view controller classes are no exception here.
However if ViewController
contains no real functionality, then you can simply remove it and derive GameViewController
directly from UIViewController
:
#import <UIKit/UIKit.h>
@interface GameViewController : UIViewController
I would be very surprised if Xcode generated both ViewController
and GameViewController
in one operation, as you imply in your question, however. If it did, then that's new to me and I cannot see why it did it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With