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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:41:45+00:00 2026-05-23T06:41:45+00:00

I have NSMutableArray named *arrWords containing list of 50 words. e.g. Bond/Bind/King/Sing/Ring etc. I

  • 0

I have NSMutableArray named *arrWords containing list of 50 words. e.g. Bond/Bind/King/Sing/Ring etc.

I use following function to display random words on screen.

-(void)displayRandomWord //This is called from timer so it randomly shows words on screen
{
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(150,150,200,30)];
    [lbl setText:[arrWords objectAtIndex:round([self randomXValueBetween:0 andValue:49])];
    [self.view addSubView:[lbl]; //this label will be removed after 1 second I have written code for that.
}
- (float)randomXValueBetween:(float)low andValue:(float)high {
    return (((float) arc4random() / 0xFFFFFFFFu) * (high - low)) + low;
}

This works fine. Now my problem is let say after certain amount of time I want to increase frequency of the particular word to be appear.

I want to setup logic like initially “Sing” is to be appeared 3 times in first 10 seconds. After 10 seconds I want it to be appear atleast 2 times more than 3 times (i.e. 5 times).

Because it is random picking of words “Sing” may appear 3 times in first 10 seconds or may not.

I am stuck here to setup logic. Any suggestions ?

  • 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-23T06:41:45+00:00Added an answer on May 23, 2026 at 6:41 am

    My first thought was to increase the amount of word “Sing” after certain time.

    What do I mean is this:

    If I have 50 words. A chance to get a “sing” word is 1/50.
    Now after 10 seconds I insert additional word “sing” to the array. Now I have 51 words in it.
    My chance of getting word “sing” just increased to” 2/51.

    That is the simplest way I could think of.

    Hope that helps.

    EDIT: I just thought that if you want to make sure that you have at least some amount.
    You could do it like this.

    If you know exactly how many words you will display in first 10 seconds? Example. 10 which is 1 per second. Then you could do this:

    Pseudocode

    word = get me a random word from array;
    displayCount = 0; number of words already displayed;
    max = 10; Displaying 10 words per 10 second
    targetWord = "Sing"
    targetWordCount = 0;  number of words targeted for this time frame;
    requiredTargetWordCount = 2; number of times a word should be displayed during the time frame
    
    for(word; displayCount < max; word.next){
       if word = targetWord
           targetWordCount ++
           display word
       else if displayCount < max - requiredTargetWordCount && targetWordCount != requiredTargetWordCount
           display targetWord  
           targetWordCount ++
    
    displayCount ++
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is
I have a NSMutableArray named as records and a NSArray . Now I am
I have two NSMutableArray 's [ nowEvents and todayEvents ] with a list of
In my iOS app, I am using a NSMutableArray, named imageMArray. I have set
I have a custom class named Profile and a NSMutableArray which I add the
I have function named: - (void) AddSortedCustomFeed :(NSMutableArray*) rssList; this function adds items(Articles) from
I Create a class named DataClass there i have this method +(NSMutableArray*) returnList :(NSString
I have three NSMutableArray containing names that are added to the lists according to
I have an NSMutableArray named as totalunits . It has some data. Each data
I have an nsmutablearray named nsmarrMedicineInfo. I want to sort the element by using

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.