Objective C sample code
Boiler plate code
- Code that almost all classes will have:
header
// Import the UIKit header file. #import <UIKit/UIKit.h> // Create constants extern NSString * const SCDonateValue1IncrementKey; // If there are other classes used, rather then importing them, use an @class. @class MainViewController. // Begin the 'interface' of the class. @interface RootViewController : UIViewController { // Declare all the variable names and types. IBOutlet UIButton *infoButton; MainViewController *mainViewController; } - (void)doSomeAction:(id)sender; - (NSString *)getSomestring; - (BOOL)isReady; // Declare the properties of the variables defined above. @property (nonatomic, retain) UIButton *infoButton; // End the 'interface' of the class. @end
implementation
// Not sure if this is required, as the @class is in the header file. #import "MainViewController.h" // Set the value of the constant. NSString * const SCDonateValue1IncrementKey = @"DonateValue1Increment"; // Begin the implementation of RootViewController. @implementation RootViewController // This creates the setters and getters for infoButton. @synthesize infoButton; // The implementation of the methods. - (void)doSomeAction:(id)sender { // The variable is sender of type id. ... } - (NSString *)getSomestring { ... } - (BOOL)isReady { ... } // End the implementation of RootViewController. @end