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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:23:23+00:00 2026-06-02T21:23:23+00:00

I am trying an array item as a the object name. I have 5

  • 0

I am trying an array item as a the object name.

I have 5 UIImageViews set up:

@interface miniTestViewController : UIViewController {

    NSArray *array;

    IBOutlet UIImageView *sun;
    IBOutlet UIImageView *moon;
    IBOutlet UIImageView *rain;
    IBOutlet UIImageView *snow;
    IBOutlet UIImageView *hail;
}

-(IBAction)fadeChosenImage:(id)sender;

My plist contains an array of image names: sun, moon, rain, snow, hail

In the .m VDL stub, this plist is read into an NSArray *array.

A UIButton tag selects the object at index:

-(IBAction)fadeChosenImage:(id)sender{

    NSString *image = [[NSString alloc] init];  
    image= nil;

    switch ([sender tag]) { 
        case 0: 
            image = [array objectAtIndex:[sender tag]]; 
            break; 
        case 1: 
            image = [array objectAtIndex:[sender tag]]; 
            break; 
        case 2: 
            image = [array objectAtIndex:[sender tag]]; 
            break; 
        case 3: 
            image = [array objectAtIndex:[sender tag]]; 
            break; 
        case 4: 
            image = [array objectAtIndex:[sender tag]]; 
            break; 
        default: 
            break;
    }

I need to use the NSString as the UIImageView object name, like this:

[[array objectAtIndex:[sender tag]] setAlpha:0];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:6.0];
[[array objectAtIndex:[sender tag]] setAlpha:1];

but so far objectAtIndex returns a NSString which does not respond to the setAlpha message.

Is it possible to convert/wrap/cast/use the NSString to the object name of the UIImageVIew

Thank you very much for any 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-02T21:23:24+00:00Added an answer on June 2, 2026 at 9:23 pm

    It would be much easier to save your image view objects into the array directly, rather than trying to retrieve them using a string.

    If you want to find objects using a string as a key, store them in a dictionary.

    Hoever, in your case, you have a numeric index. Just save the UIImageView objects directly into your array. That does not duplicate the objects – it just saves references to them in your array.

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

Sidebar

Related Questions

I am trying to reorder an array (moving one item of 90 to the
I am trying to create an JSON object out of a PHP array. The
I'm trying to get an item of an array by its key. The array
I have my shared user defaults plist that looks something like: menuItems (Array) Item
I'm trying to create a controller for a custom complex object but have some
I am trying to array posts containing the value X within their meta_value. I’ve
I am trying to sub-array in MATLAB with no luck. This is what I
I am trying to pass array parameter to SQL commnd in C# like below,
I'm trying to subclass Array in ruby to make it randomize its elements when
I am trying to sort array with usort, but it doesn't work, What am

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.