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

The Archive Base Latest Questions

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

This is my first question on this forum and I hope u don’t blame

  • 0

This is my first question on this forum and I hope u don’t blame me. I’m trying to make an app and need some help with NSMutableArray.

I declared in .h file some UIIMageView objects like this:

IBOutlet UIImageView *image1;
IBOutlet UIImageView *image2;
NSMuttableArray *images;

In .m file i set up the Hidden:YES.
Also I inserted them in an NSMuttableArray like this:

images = [[NSMutableArray alloc] initWithCapacity:2];
    [images addObject:image1];
    [images addObject:image2];
  1. How can I set up now a random UIImageView from the Array to be setHidden:NO?
  2. How to remove that object from the Array after it’s set up as not hidden?
  3. After an action like -(IBAction) btnclick {} to make it again Hidden and show next random image from this NSMuttableArray in case they r much more.
  • 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-09T16:29:53+00:00Added an answer on June 9, 2026 at 4:29 pm

    This is probably what you want to do:

    (also I’ll make it an array of UIImages since that is the way you should present random images imo but then again you can do this with UIImageViews as well, which is again not recommended)

    -(void)buttonClickedMethod
    {
        if(images.count > 0)
        {
            int randomValue = arc4random_uniform(images.count); //get yourself a nice random value as used in http://stackoverflow.com/questions/160890/generating-random-numbers-in-objective-c
            myImageView.image = [images getObjectAtIndex:randomValue]; //get yourself the random image and set it to your UIImageView (which you probably want it to be image1 or image2 in your case)
            [images removeObjectAtIndex:randomValue]; //remove the random image from you list so that you want get it again the next you click the button
        }
    }
    

    This is probably the best way to deal with your problem.

    You might want to add a method that removes the random image from the image view afterwards but then again you might not.

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

Sidebar

Related Questions

This is my first question to this forum. I am trying to make this
this is my first question in the forum, I hope you can help me
This is my first question in this forum, so i hope to be clear:
This is my first question on Stack Overflow, so I hope that I'm clear
This is my first question, so please be gentle. I'm trying out Apache Camel
this is my first question on stack overflow. Some quick background, this is not
(Since this is my first SO question, let me just say I hope it's
It is the first time I ask a question on this forum. Sorry if
This is my first question here, but I hope I will get a lot
I am new the forum so hope this question is not too elementary or

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.