Like most, I recently downloaded the latest version of XCode (4.3.1). I've noticed that as I'm creating new UIViewController
objects, the associated .m
files contain additional class definition code that I haven't ever seen before.
Specifically, if I create a new UIViewController
named 'TestViewController', I get the following .m
file output.
\\... removed comments...
#import "TestViewController.h"
@interface TestViewController ()
@end
@implementation TestViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
\etc...
The newly added code since XCode 4.3 is the portion under the #import
statement:
@interface TestViewController ()
@end
What is the purpose this code? Can/should anything go within the parenthesis? Should any code go within the @interface
and @end
statements?
In short, what was the point of adding this code to the template? As an interesting side note, when I tried creating an NSObject
from a template, the above mentioned snippet of code wasn't added. It might appear with other types class templates but at the moment I've only encountered it with UIViewController
and UITableViewController
objects.