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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:43:36+00:00 2026-05-12T08:43:36+00:00

I need a simple structure to store polygon names based on sides … so

  • 0

I need a simple structure to store polygon names based on sides … so for e.g. 1 side is “monogon”, 2 sides is “digon”, 3 sides is “triangle” and so on (say for upto 12 sides)
What is the simplest way to store these and reuse them in the code dynamically? for e.g. if my polygonShape class has 3 as the number of sides, it should return “Triangle” as the name (which is a property declared in the class) ( I am using Obj-c). I thought of 3 options

1. enums

typedef enum {monogon = 1, digon, triangle, ...}

But then realized this is reverse of what I need. They would actually encode the numbers for me to a string. I need to obtain the names from the numbers.

2. switch-case statements – came as close alternative

3. Arrays – Then I thought may be use arrays and their indexes map to Strings

Somehow I feel I might be missing something in the “too-simple-to-be-true” solution of arrays.
Any opinions appreciated.

  • 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-12T08:43:36+00:00Added an answer on May 12, 2026 at 8:43 am

    I think an array would be the way to go. Only catch, is that an array starts at 0 so you’d have to store something like an empty string in index zero, or always subtract 1 from you number of sides to get the proper index. You can’t store nil in index zero since it is used to mark the end of the array. The other approach could be a NSDictionary so you don’t have to deal with index zero. You would simply have NSStrings 1 – x as your keys, and then the NSStrings of mongon, digon, triangle,… as your objects in the array. Hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 176k
  • Answers 176k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want to allow user to input HTML, and… May 12, 2026 at 3:17 pm
  • Editorial Team
    Editorial Team added an answer In my experience, it's pretty tough to find these guys.… May 12, 2026 at 3:17 pm
  • Editorial Team
    Editorial Team added an answer You could probably do this a lot easier by writing… May 12, 2026 at 3:17 pm

Related Questions

I need a simple structure to store polygon names based on sides ... so
I am attempting to build a .PLY parser to load 3d models stored as
I have a console application that I am rebuilding from C to C#. This
I'm working on something of a wizard-type application to allow users to build simple
How would look like a simple script ( cmd.exe batch, *nix shell , perl

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.