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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:29:45+00:00 2026-06-08T13:29:45+00:00

I want to show different set of strings with different calculation depends on the

  • 0

I want to show different set of strings with different calculation depends on the sender’s response..2 sets of strings are parallel, which means the naming is like.. user1, user2, object1, object2, name1, name2, age1, age2, etc..what I know so far is to use…

-(IBAction)showLotOfStuff:(id)sender{
switch ([sender tag]) {
case 1: //show user1, object1, name1, age1...
case 2: //show user2, object2, name2 age2...}

However, by then I will have double size and repetitive codes as I have a lot to do and show..it’s really dumb, it involves array, calculation and I really dun want to see it twice, though I can do it by simply copy and paste..

I wonder if there is any way I can cut half of them by doing..

-(IBAction)showLotOfStuff:(id)sender{
show user[sender tag], object[sender tag], 
name[sender tag], age[sender tag]...}

this question is quite basic I think, but I just can’t figure out how to do it..
Thx for your help!

  • 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-08T13:29:46+00:00Added an answer on June 8, 2026 at 1:29 pm

    Do you have an array of users? What does your data look like? You can probably refactor this and not duplicate code.

    Let’s say you have an NSArray called users.

    Not sure what kind of controls you are using, but for simplicity’s sake we can assume you have some buttons, each of which should display the info for one of the users. You can give the buttons tags corresponding to the position of the user of the array, ideally with some offset to reduce the chance of making a mistake an using those tags for something else. (ie let’s assume you have 3 buttons with tags 100, 101, and 102, and 3 users in your array).

    Then you can just do something like:

    - (IBAction)showLotOfStuff:(id)sender
    {
      int userIndex = sender.tag - 100; // you could define 100 as a constant called userOffset or something to make this a little cleaner
      if(users.count <= userIndex)
        return; // out of bounds, probably want to check for this and handle it somehow
    
       MyObjectType *currentUser = [users objectAtIndex:userIndex];
       // do whatever with your user
    }
    

    This is a general example. The specific implementation depends on more details you haven’t provided.

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

Sidebar

Related Questions

I want to show array objects at the same time in different 10 labels.
In my Rails controller I want to branch to a different controller's action, show
How to set the color of margins in a QGridLayout? I want to show
I want to set different title for alert dialog when WebView page is loaded
I would like to show something similar to a progressbar by using different images,
I want show an information page after success db opartions. And after the info
I want show annotation view (above one of my pin) after load map. For
hii I want show a pop up Dialog box when i click on to
I'm using Drupal 7 and Views module in my site. And want show number
I want to show a border type look for an element but without using

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.