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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:08:52+00:00 2026-05-28T14:08:52+00:00

I’m new to Objetive-C and need some help, I have an Array with 22

  • 0

I’m new to Objetive-C and need some help,

I have an Array with 22 UIImage’s and 4 UIButtons on the view.
I want to take an image from the array with ObjectAtIndex:somecounter and place this image randomly in one of the 4 UIButton’s, than I want to take another 3 UIImages from the Array (random images) and locate them randomly in the other 3 UIButtons that I have left.

so in each time that the counter is in a number, take the UIImage that stored in this index, locate it randomly in one of the UIButtons, than take other 3 random UIImages from the Array and locate them randomly on the 3 UIButton that I have left.

how can I do that?

after using basvk answer came up with this:

-(void)PlaceWordAndPictueOnScreen
{
    NSArray *buttons = [NSArray arrayWithObjects:btnLetter1, btnLetter2, btnLetter3, btnLetter4, nil];
    for (UIButton *btn in buttons) {
        int randomIndex= random() % [LettersArray count];
        UIImage *img = [LettersArray objectAtIndex:randomIndex];
        [btn setImage:img forState:UIControlStateNormal];
        [LettersArray removeObjectAtIndex:randomIndex];                        
    }
}

so I did exactly as he said and it worked like charm, but, I do have a problem.
I have this counter called ‘imgcounter’, lets say he’s value is ‘4’, I want to take the image that located at index 4 and put it in one of the ‘btnLetter’ UIButton, but in a random button, than in the other 3 ‘btnLetter’ buttons that left, to put another 3 random UIImage’s, how can I do that?

Thanks..

  • 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-28T14:08:53+00:00Added an answer on May 28, 2026 at 2:08 pm

    Out the top of my head, something like this:

      -(void)placeImages {
            NSMutableArray *images = [NSMutableArray arrayWithObjects:@"image1.png", @"image2.png", @"image3.png", @"image4.png", @"image5.png", @"image6.png", @"image7.png", @"image8.png", nil]; // etc...
            NSArray *buttons = [NSArray arrayWithObjects:btn1, btn2, btn3, btn4, nil];
            for (UIButton *btn in buttons) {
                  int randomIndex= random() % images.length;
                  UIImage *img = [images objectAtIndex:randomIndex];
                  [btn setImage:img forState:UIControlStateNormal];
                  [images removeObjectAtIndex:randomIndex];                        
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6

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.