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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:02:32+00:00 2026-06-17T14:02:32+00:00

I am new to Objective-C and X-Code and basically programming in iOS so this

  • 0

I am new to Objective-C and X-Code and basically programming in iOS so this may be a very simple question.
Anyway, I’m trying to make a logo quiz wherein the logos and the choices are generated in random order i.e. (Logo 1) — Choices: A B C D for the first try. Then the next time the user opens the app, Logo 4 appears first with choices A D B C. (I hope that’s clear). I’ve managed to randomly display the logos but can’t figure out how to do the same for the choices which would modify the value of 4 buttons below the logo.

From what I’ve search, you use something like:

 [btnA setTitle:@"answer" forState:UIControlStateNormal];

My problem is, I’m thinking of putting the choices into an array as well so I tried something such as this:

[btnA setTitle:[answerArray objectAtIndex:i] forState:UIControlStateNormal];]

Similar to what I’ve done for the logos but I’m not getting any values for the button. Is there something I’m missing here? I don’t get any errors either. Here’s a part of my code that might better explain what I’ve been trying to do:

NSMutableArray *answerList = [[NSMutableArray alloc] initWithObjects:
                               @"AnswerA",
                               @"AnswerB",
                               @"AnswerC",
                               nil];
answerArray = answerList;
int i = arc4random() % [answerArray count];
[self.btn1 setTitle:[answerArray objectAtIndex:i] forState:UIControlStateNormal];
[self.btn2 setTitle:[answerArray objectAtIndex:i] forState:UIControlStateNormal];
[self.btn3 setTitle:[answerArray objectAtIndex:i] forState:UIControlStateNormal];
  • 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-17T14:02:33+00:00Added an answer on June 17, 2026 at 2:02 pm

    See following code – it can generate random title from set of 100:

    -(int)getRandomNumber:(int)fromVal to:(int)toVal {
        return (int)fromVal + arc4random() % (toVal-fromVal+1);
    }
    
    -(void) setButtonTitle
    {
        NSArray * buttonTitleArray = [NSArray arrayWithObjects:@"title1", @"title2",... @"title100", nil};
        int x = [getRandomNumber :0 :100];
        NSString * title = [buttonTitleArray objectAtIndex:x];
        [button setTitle:title :forState:UIControlStateNormal];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to programming and Objective-C and I am trying to work
I'm new to objective-C programming for iOS. I'm struggling with a really simple task,
I am new to Objective-C and I have no clue why this code is
I'm new in objective-c, and I'm now trying to write a simple user-sign-in program
I am new to Objective-C programming. In many tutorials I have been seeing code
I am still new in objective-c programming, I got this exception, but I don't
Being fairly new to objective-c and developing for ios I'm trying to figure out
I'm new to HTML; however I have programming experience with Objective-C, here's my code:
I'm fairly new to objective c but I'm using this code NSURL *url =
I am new to iOS development. I've recently stumbled upon the new objective-c collection-literals

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.