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

  • Home
  • SEARCH
  • 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 697403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:09:52+00:00 2026-05-14T03:09:52+00:00

In sample code, I have seen this: typedef enum Ename { Bob, Mary, John}

  • 0

In sample code, I have seen this:

typedef enum Ename { Bob, Mary, John} EmployeeName;

and this:

typedef enum {Bob, Mary, John} EmployeeName;

and this:

typedef enum {Bob, Mary, John};

but what compiled successfully for me was this:

enum {Bob, Mary, John};

I put that line in a .h file above the @interface line, and then when I #import that .h file into a different class’s .m file, methods there can see the enum.

So, when are the other variants needed?

If I could name the enum something like EmployeeNames, and then, when I type “EmployeeNames” followed by a “.”, it would be nice if a list pops up showing what the enum choices are.

  • 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-05-14T03:09:52+00:00Added an answer on May 14, 2026 at 3:09 am

    In C (and hence Objective C), an enum type has to be prefixed with enum every time you use it.

    enum MyEnum enumVar;
    

    By making a typedef:

    typedef MyEnum MyEnumT;
    

    You can write the shorter:

    MyEnumT enumVar;
    

    The alternative declarations declare the enum itself and the typedef in one declaration.

    // gives the enum itself a name, as well as the typedef
    typedef enum Ename { Bob, Mary, John} EmployeeName;
    
    // leaves the enum anonymous, only gives a name to the typedef
    typedef enum {Bob, Mary, John} EmployeeName;
    
    // leaves both anonymous, so Bob, Mary and John are just names for values of an anonymous type
    typedef enum {Bob, Mary, John};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thread reading data from a bluetooth stream that sends the data
I am building a news app (TabBar app) where I have to load top
Hopefully this is simple enough. I need to be able to add elements to
I have been asked to make a few cosmetic changes to our production deployment.
I have developed an applet java with Eclipse, which is included in MyPage.html. I
I have a Answer table which has pk_answerid, answertext , fk_questionid, chosenoptions stored as
My program outputs state of computations to the terminal and includes quite a bit
I am trying to debug a weird issue I am experiencing with a MVC2
I'm looking for a way to create a simple HTML table that can be
Possible Duplicate: XFBML and the Facebook Login button I'm trying to add the Login

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.