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 8400135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:29:12+00:00 2026-06-09T21:29:12+00:00

I am trying to display the value stored a particular value of enum using

  • 0

I am trying to display the value stored a particular value of enum using NSLog. In the following example, I am trying to get the output as: 5 represents month of May.

Any idea what is the right token to use for enum with NSLog? I tried using %i and %@, but both do not work.

Thanks!

enum month {jan = 1, feb, march, apr, may, jun, jul, aug, sep, oct, nov, dec};
enum month amonth;
int x = 5;
amonth = x;
NSLog(@"%i represents month of %@", x,amonth);
  • 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-09T21:29:13+00:00Added an answer on June 9, 2026 at 9:29 pm

    Unfortunately, what you’re asking for is not possible. Enum names are not preserved past compilation (except as debugging information available to the compiler). So unless you want to a) ship debugging information in your app, and b) effectively write a debugger inside your app that uses the embedded debugging information, it’s just not going to work.

    The typical solution to this problem is to provide a function that returns the appropriate name, using a switch statement.

    NSString *monthName(enum month m) {
        switch (m) {
            case jan:
                return @"jan";
            case feb:
                return @"feb";
            ...
        }
        return @"unknown";
    }
    

    One benefit of this approach is you can localize the names.

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

Sidebar

Related Questions

I'm trying to get the $url value to display from the MySQL database but
i am trying to get the value from my methods and display it in
I am trying to display the value returned by a stored procedure in a
I am trying to display a default value (or even NO value) when selected
I'm trying to change the value of a dojo tree to display the correct
I am trying to display filenames in a listbox, retrieved from a particular directory.
I am trying to display a number, stored in a dataset as a string,
2 Hi! I am trying to create stored procedure that gone return varchar value,
I'm trying to display images stored in MSSql Db as varbinary, when execute my
I'm trying to display a notification using Easy Notification , but I don't want

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.