There’s a few different ways to create constants in Objective-C, but the easiest way is to use #define statements.

To start, create a new header file. This is where we’ll store all the constants. Name it something original like “Constants.h”.

Here’s a sample file with a few constants:

//
//  Constants.h
//  App Name
//
//  Created by Miscellanea on 10/27/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#define NUM_SECTIONS        7

#define NUM_SECTION_1_ITEMS 2
#define NUM_SECTION_2_ITEMS 14
#define NUM_SECTION_3_ITEMS 5

#define APP_TITLE           @"App Name"
#define APP_AUTHOR          @"Miscellanea"


To use these constants in your project, you need to import your header file in each implementation file (*.m) where you’ll be referencing them.

#import "Constants.h"

– (void)viewDidLoad
{
    self.title = APP_TITLE;

    for (int i = 0; i < NUM_SECTIONS; ++ i)
    {
        // etc.
    }
}


If you’d like to go beyond simple preprocessor directives and implement a full blown Constants.h/m pair, then check out this thread over at Stack Overflow.