Return to   |   Check out   |   How to Post Snippets  

Not registered? Thats okay! You can Submit a Snippet without being a member of this site!


I just recently started using a Globals.h file as my staging ground for my macros. Where ever you want to use any of the macros, just use #import "Globals.h". You can use this file to store an AppDelegate instance and many other static options you wish to use.

Here is an example of what one of my Globals.h would look like:

//  Globals.h
//  My App Name
//  Created by Aaron Wright on 5/14/11.
//  Copyright © 2011 Wright's Computer Services. All rights reserved.

#import "MyApp_AppDelegate.h"

#pragma mark Custom Macros

    #define APP            [UIApplication sharedApplication]
    #define APPDELEGATE    (MyApp_AppDelegate*)[[UIApplication sharedApplication] delegate]

    #define RELEASE_SAFELY(__POINTER)  { [__POINTER release]; __POINTER = nil; }

#pragma mark - Device Specific

    #define IPAD     UIUserInterfaceIdiomPad   
    #define IPHONE   UIUserInterfaceIdiomPhone

#pragma mark - Appearance

    #define USER_FONT   [UIFont fontWithName:@"Verdana" size:16.0f]

/*  gcc requires there be at least 1 blank line at the end of the file  */

Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© Copyright 2011 Wright's Computer Services.   All rights reserved Suffusion theme by Sayontan Sinha