Question: I'm trying to write a custom macro that performs some action when called it. 

Here is my constants file:

```
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

#define SHOW_VIEW [(AppDelegate*)[UIApplication sharedApplication].delegate showView]

#define HIDE_VIEW [(AppDelegate*)[UIApplication sharedApplication].delegate hideView]

```

and I created a pch file:

```
#ifndef MYPrefixHeader_pch
#define MYPrefixHeader_pch

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.

#ifdef __OBJC__
#import "MYGlobals.h"
#endif

#endif /* MYPrefixHeader_pch */

```

and in my view controller, I'm trying to call the macro:

```
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    SHOW_VIEW;
}

```

And I see errors on the line SHOW\_VIEW :

[![enter image description here](https://i.stack.imgur.com/q6K5d.png)](https://i.stack.imgur.com/q6K5d.png)

Answer: 
Include your app delegate in the constants header `MYGlobals.h`

```
#import "AppDelegate.h"

```

I would urge to reconsider this method to get more readable and consistent code. Instead, what you can do is define a macro for your app delegate instance.

```
#define MY_APP_DELEGATE ((AppDelegate *)[UIApplication sharedApplication].delegate)

```

Then call its methods directly:

```
[MY_APP_DELEGATE showView];
[MY_APP_DELEGATE hideView];

```
You are having syntax errors in your macro.

```
#define SHOW_VIEW [(AppDelegate*)[UIApplication sharedApplication].delegate showView];

#define HIDE_VIEW [(AppDelegate*)[UIApplication sharedApplication].delegate hideView];

```

Also you need to include the `#import "AppDelegate.h"` in the `prefix.pch` file.