Objective C sample code

Boiler plate code

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


Browse Space

- Pages
- Blog
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content