Reputation: 492
When I go into xcode try to add a new class with File>New>New File and then adding an Objective C class, my header file winds up looking like this:
@interface Course : NSObject
@end
instead of what it needs to look like
@interface Course : NSObject {
@private
}
@end
is there any reason for this, I'd really like to have it set up the way that the code snippet does (the second) by default.
Upvotes: 0
Views: 218
Reputation: 52778
In the
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Cocoa Touch/Objective-C class.xctemplate/NSObject
directory there are template files called ___FILEBASENAME___.m
and ___FILEBASENAME___.h
. What you need to do is change the ___FILEBASENAME___.h
file (using something like vim, TextWrangler, etc) from this:
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
//
___IMPORTHEADER_cocoaTouchSubclass___
@interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___
@end
To this:
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
//
___IMPORTHEADER_cocoaTouchSubclass___
@interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ {
@private
}
@end
Poke around in /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/
and /Developer/Library/Xcode/Templates/File Templates
to see more templates you can customize.
Or use this python script I wrote to customize them all automatically (after tweaking the python script to fit your customization needs):
http://blog.hozbox.com/2011/11/20/easy-xcode-template-customization/
Upvotes: 3
Reputation: 25281
Looks like this is normal behavior for Xcode 4.2. The new runtime does not require the creation of instance variables when you use properties.
Old runtime:
@interface Foo : NSObject
{
NSNumber *myNumber;
}
@property (nonatomic, retain) NSNumber *myNumber;
@end;
New runtime:
@interface Foo: NSObject
@property (nonatomic, retain) NSNumber *myNumber;
@end;
Upvotes: 3