Templates for @interface and @implementation files

I’m always checking where I have to put my instance variables and whether I need braces so I just created a simple template that I use to check when necessary.

Interface Template

#import <UIKit/UIKit.h>

@class ClassForwardDeclaration;

@interface MyClass : NSObject  {
    NSString   *myString;  // publicly accessible instance variable

@property (nonatomic, strong) IBOutlet UILabel *someLabel;

- (IBAction)someActionMethod:(id)sender; 


Implementation Template

#import "MyClass.h"

#define kPublicDefine @"something public"

@interface MyClass()
@property (nonatomic, strong, readwrite) NSURLRequest *request; // properties private to this class

@implementation MyClass {
     int someNumber; // private instance variable

#define kPrivateDefine @"something private"

- (void)viewDidLoad



More here:
and a post re private instance variables in the .m file here:

Leave a Reply

Your email address will not be published. Required fields are marked *