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 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 nested ObsevableCollections as seen below. For simplistic reason this is sample code
I have seen sample source code around that uses different ways of releasing/dealloc'ing objects,
I have this sample code for async operations (copied from the interwebs) public class
I have seen sample code similar to the following: std::string s = Hello World!;
I have seen iCloud Document sample code for iOS and I used it to
i go through a code sample where i have seen a different way to
I have seen similar questions to this, but they involve different types so I
I have seen this code in web.xml file <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> I build small
This is a code that will attempt to record an audio sample : but
I've seen some sample code that does this: proc_entry->read_proc = module_read; proc_entry->write_proc = module_write;

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.