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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:10:00+00:00 2026-05-15T20:10:00+00:00

i was playing around with an idea. in a single lable in a view

  • 0

i was playing around with an idea. in a single lable in a view when the view appears a random number is displayed. presently i have aview, a lable and a button. press button random number is generated and the lables title is replaced with a random number….random number displayed.

what i wish to acheive is that there is no button, just a view and a text lable and when the view appears a random number is displayed also instantaneously with out the need for a button to prompt generation.
here isi the code i have so far

#import "Mainview.h"

@implementation Mainview
- (IBAction)pushstart {

    NSString *title = nil;
    NSString *path = nil;

    int Number = arc4random() % 12;
    switch(Number) {
                    case 0:
                    namel.text = @"1";

                    break;
          case 1:
                    namel.text = @"2";

            break;

        case 2:
                    namel.text = @"3";

                    break;

        case 3:
                    namel.text = @"4";

                    break;

        case 4:
                    namel.text = @"5";

                    break;
        case 5:
            namel.text = @"6";

            break;

        case 6:
            namel.text = @"7";

            break;

        case 7:
            namel.text = @"8";

            break;

        case 8:
            namel.text = @"9";

            break;



        case 9:
            namel.text = @"10";

            break;

        case 10:
            namel.text = @"11";

            break;

        case 11:
            namel.text = @"12";

            break;


                            break;
                    default:
                    break;
    }


}
@end
  • 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-15T20:10:01+00:00Added an answer on May 15, 2026 at 8:10 pm

    Here is the way shorter answer, this method goes in whatever class is controlling the view (same place as the current action method):

    - (void) awakeFromNib {
        srandom(time(NULL));
        [namel setIntValue: random %12];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am playing around with xpath, but have no Idea how to for example
I am just playing around with WordPress and neither I have any idea abt
Pleasantries I've been playing around with this idea for a couple of days but
I am playing around with a xul browser element in a sidebar (the idea
While playing around with the emulator, I noticed that when trying to view a
I'm currently playing around with a CMS idea I've got. It's based on a
After playing around with AMD/RequireJS I was wondering if it is a good idea
in playing around with the idea of using a webservice for my project I
I am currently playing around with the idea of having history tables for some
I was playing around with some code today, and I came across the idea

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.