Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:15:16+00:00 2026-06-17T15:15:16+00:00

I have pch-file with this code: #import ServerModel.h enum { SAVE = 1, REMOVE

  • 0

I have pch-file with this code:

#import "ServerModel.h"

enum {
    SAVE = 1,
    REMOVE = 2,
    REMOVE_ALL = 3
};
typedef NSInteger RequestType;

and I’m trying to use RequestType in ServerModel.h but compiler doesn’t know nothing about my enum. I tried to create header file for my enums and import this file in pch-file but nothing have changed.

So basic problem is: I can’t use enums from .pch file in files, that are #imported in this pch-file.

Is there some way to handle this problem? And is pch-file good place to put enums there?

UPD:

I tried to put all this enums in one header file and #import this file in the end of all #imports in pch-file and it doesn’t work.
But then I put

#import "Enums.h" // my file with enums

in the beginning of pch-file, before all other #imports and it’s working.

I will be glad if somebody will explain the difference in the placement of #import before or after some other #import.

UPD2:

I’ll try to make it more clearly:

I have Enums.h with enum:

enum {
    SAVE = 1,
    REMOVE = 2,
    REMOVE_ALL = 3
};
typedef NSInteger RequestType;

MyProject-Prefix.pch with:

#import "ServerModel.h"
#import "Enum.h"

and ServerModel.h with following code:

- (void)unlinkAccountWithRequestType:(RequestType)requestType;

I’m getting an error: Expected a type on this method. I’ve cleaned my project and getting same error.

When I’m switching #imports like this:

#import "Enums.h"
#import "ServerModel.h"

Everything is good

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:15:17+00:00Added an answer on June 17, 2026 at 3:15 pm

    Case1 : If you import like this

    #import "ServerModel.h"
    #import "Enums.h"
    

    Then compiler will check ServerModel.h file before Enums.h when it encounters #import "ServerModel.h" statement. And while checking you ServerModel.h it finds a token RequestType and says WTF is RequestType?? and throws error on your face.

    Case 2: If you write this

    #import "Enums.h"
    #import "ServerModel.h"
    

    Then compiler compiles Enums.h successfully and then compiles ServerModel.h and again it finds a token RequestType and says yeah I know this is a typedef of NSInteger which is defined in Enums.h. And finally it moves on happily.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: #include <stdio.h> #include <string.h> int main() { char buf[255]; char
This is my .pch file - // // Prefix header for all source files
I've been trying to debug this issue for weeks now and I have made
I have this example code for the strchr function in C. /* strchr example
I have following macro in my PCH file. #ifdef DEBUG #define MYLOG(...) NSLog(__VA_ARGS__) #else
I included a header in my prefix.pch file as so: #import <Availability.h> #ifndef __IPHONE_3_0
I'm trying to implement the logging approach at http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ . I'm not sure how
I have created #define statement in project's pch file so it can be seen
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.