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 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

Related Questions

I need to store some data that follows the simple pattern of mapping an
I need a simple way to monitor multiple text log files distributed over a
I need a simple table with a user name and password field in MySQL.
I need a simple app to edit database tables. Are there any code generators
I need a simple window with three input boxes and three labels (login name,
I need a simple SQL to accomplish the below: Problem: When a petrol bunk
I need a simple function which will take a FileInfo and a destination_directory_name as
For a random event generator I'm writing I need a simple algorithm to generate
Well... that's it. I need something simple and reliable (doesn't have to have fancy
I need to create simple reusable javascript object publishing several methods and parameterized constructor.

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.